Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static factories for schema builders. #9

Open
Sergej-Popov opened this issue Dec 18, 2019 · 0 comments
Open

Static factories for schema builders. #9

Sergej-Popov opened this issue Dec 18, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@Sergej-Popov
Copy link
Collaborator

As per the suggestion in #8 PR review.

Create static builder factories for creating schema objects.
Such fluent builders will be more convenient to use and easier to discover the API with IntelliSense.
For example:

const schema = new Schema<Model>()
        .with(m => m.StringProp, new AnyOf([
          "specificValueNotMatchingRegex",
          /^[A-z]+\.[A-z]+$/,
          new StringSchema({
            enum: ["123"]
          })
        ]))
        .build();

could be expressed as something like

      const schema = new Schema<Model>()
        .with(m => m.StringProp, jsonschema.matching.anyOf([
          "specificValueNotMatchingRegex",
          /^[A-z]+\.[A-z]+$/,
          jsonschema.string.exactMatch("123")
        ]))
        .build();
@Sergej-Popov Sergej-Popov added the enhancement New feature or request label Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant