fastify / fastify/fluent-json-schema

Add Support for custom format input

Open
#250 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
526
Forks
58
PR merge metrics
No merged PRs in 30d

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested

### 🚀 Feature Proposal

Currently, if I call `S.string().format('myformat')`, it throws following error:
```
throw new FluentSchemaError(
FluentSchemaError: 'format' must be one of relative-json-pointer, json-pointer, uuid, regex, ipv6, ipv4, hostname, email, url, uri-template, uri-reference, uri, time, date, date-time
```
This makes it difficult to use any custom format with this library. We should provide option to customize this behavior to support custom formats.

### Motivation

I am using ajv for validation, ajv supports adding custom user defined format - [Format validation](https://ajv.js.org/guide/formats.html), which takes validate function in which one write any js code to validate the input. Now since this library only takes well defined formats, it's difficult to use this library with ajv.

### Example

`S.string().format('myformat')`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.