fluent-json-schema icon indicating copy to clipboard operation
fluent-json-schema copied to clipboard

Add Support for custom format input

Open shivamkj opened this issue 1 year ago • 0 comments

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, 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')

shivamkj avatar Jul 18 '24 08:07 shivamkj