Skip to content

v0.6.0

Compare
Choose a tag to compare
@aboutlo aboutlo released this 01 Feb 21:53
· 212 commits to master since this release

New Features

  • New Syntax more compact
  • Support for Mixed type
  • Refactor Typescript types
  • Complete internal refactor to manage in a better way all the types:
    • BaseSchema (id, title, example, required, etc.)
    • StringSchema (format, pattern, etc)
    • ArraySchema (items, etc)
    • ObjectSchema (properties, etc)
    • NumberSchema (min, max, etc)
    • IntegerSchema (min, max, etc)
    • BooleanSchema
    • NullSchema
  • Coverage 99%

Fixes:

New syntax

const S = require('fluent-schema')
const schema = S.object()
  .id('http://foo/user')
  .title('My First Fluent JSON Schema')
  .description('A simple user')
  .prop(
    'email',
    S.string()
      .format(S.FORMATS.EMAIL)
      .required()
  )
  .prop(
    'password',
    S.string()
      .minLength(8)
      .required()
  )
  .prop('role', S.enum(['ADMIN', 'USER']).default('USER'))
  .definition(
    'address',
    S.object()
      .id('#address')
      .prop('line1')
      .required()
      .prop('line2')
      .prop('country')
      .required()
      .prop('city')
      .required()
      .prop('zipcode')
      .required()
  )
  .prop('address')
  .ref('#address')