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

Inconsistent "schemaPath" for errors #262

Open
varoot opened this issue Sep 18, 2017 · 0 comments
Open

Inconsistent "schemaPath" for errors #262

varoot opened this issue Sep 18, 2017 · 0 comments

Comments

@varoot
Copy link

varoot commented Sep 18, 2017

schemaPath that were returned from validateResult are not always consistent. For example, multipleOf rule are not included:

const schema = {
  type: 'object',
  properties: {
    num: {
      type: 'number',
      minimum: 5,
      multipleOf: 2,
    },
  },
};

// schemaPath missing "multipleOf"
tv4.validateResult({ num: 1 }, schema);
// {
//   error: {
//     message: "Value 1 is not a multiple of 2",
//     params: {
//       value: 1,
//       multipleOf: 2
//     },
//     code: 100,
//     dataPath: "/num",
//     schemaPath: "/properties/num",
//     subErrors: null,
//     stack: "(...omitted...)"
//   },
//   missing: [],
//   valid: false
// }

tv4.validateResult({ num: 2 }, schema);
// {
//   error: {
//     message: "Value 2 is less than minimum 5",
//     params: {
//       value: 2,
//       minimum: 5
//     },
//     code: 101,
//     dataPath: "/num",
//     schemaPath: "/properties/num/minimum",
//     subErrors: null,
//     stack: "(...omitted...)"
//   },
//   missing: [],
//   valid: false
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant