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

fix: schema-based validation does not work #611

Closed
thorek opened this issue May 14, 2020 · 3 comments
Closed

fix: schema-based validation does not work #611

thorek opened this issue May 14, 2020 · 3 comments
Labels
priority: low status: duplicate Issue is being tracked already in another issue. type: fix Issues describing a broken feature.

Comments

@thorek
Copy link

thorek commented May 14, 2020

Tested with the example from the README - the following validation will always show "Validation succeed".
Even in case the object should not pass.

 let UserValidationSchema: ValidationSchema = { // using interface here is not required, its just for type-safety
    name: "myUserSchema", // this is required, and must be unique
    properties: {
        firstName: [{
            type: "minLength", // validation type. All validation types are listed in ValidationTypes class.
            constraints: [2]
        }, {
            type: "maxLength",
            constraints: [20]
        }],
        lastName: [{
            type: "minLength",
            constraints: [2]
        }, {
            type: "maxLength",
            constraints: [20]
        }],
        email: [{
            type: "isEmail"
        }]
    }
  };
  registerSchema(UserValidationSchema); // if schema is in .json file, then you can simply do registerSchema(require("path-to-schema.json"));
  const user = { firstName: "J", secondName: "Cage", email: "johny", some: "thing" };
  validate("myUserSchema", user).then(errors => {
      if (errors.length > 0) {
          console.log("Validation failed: ", errors);
      } else {
          console.log("Validation succeed.");
      }
  });
@ozzywalsh
Copy link

Duplicate of #595.

@NoNameProvided
Copy link
Member

Schema-based validation will be deprecated in the future probably as a result marking this as low prio.

@NoNameProvided NoNameProvided changed the title Schema-based validation does not work. fix: schema-based validation does not work Aug 9, 2020
@NoNameProvided NoNameProvided added priority: low status: duplicate Issue is being tracked already in another issue. type: fix Issues describing a broken feature. labels Aug 9, 2020
@github-actions
Copy link

github-actions bot commented Sep 8, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: low status: duplicate Issue is being tracked already in another issue. type: fix Issues describing a broken feature.
Development

No branches or pull requests

3 participants