Skip to content

Differentiate schemas by type  #22

@aboutlo

Description

@aboutlo

it's a large refactoring in order to move toward 1.0

Create:

  • 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
  • Refactor Typescript types

New syntax

const schema = FluentSchema()
      .id('http://bar.com/object')
      .title('A object')
      .description('A object desc')
      .prop(
        'name',
        FluentSchema()
          .asString()
          .id('http://foo.com/string')
          .title('A string')
          .description('A string desc')
          .pattern(/.*/g)
          .format('date-time')
      )
      .valueOf()

it wont hint for wrong types like:

StringSchema().min(5) // Number validation keywords

or

FluentSchema().minLength(10) // String validation keywords

This allows:

  • better code hitting by type
  • smaller implementation files
  • Tests by type

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions