Skip to content

improve multi validate #210

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

Closed
wants to merge 0 commits into from
Closed

improve multi validate #210

wants to merge 0 commits into from

Conversation

0x0a0d
Copy link
Contributor

@0x0a0d 0x0a0d commented Dec 24, 2020

in multi check process, the value passed throw validate function that can changes the original value (type 'object' with strict 'remove')
example:

const Validator = require("fastest-validator");

const v = new Validator();

v.alias("targetA", {
  type: "object", strict: "remove", props: {
    a: "string"
  }
});

v.alias("targetB", {
  type: "object", strict: "remove", props: {
    b: "string"
  }
});

const schema = {
  tester: ["targetA", "targetB"]
};

v.validate({ tester: {a: "ok"} }, schema);
v.validate({ tester: {b: "not-ok"} }, schema);

this pull includes

  • add clone, removeChildrenAndMerge method to validator
  • add context.validator that ref to validator instance

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.404% when pulling 6a28075 on 0x0a0d:master into 34ebcb4 on icebob:master.

@coveralls
Copy link

coveralls commented Dec 24, 2020

Coverage Status

Coverage increased (+0.01%) to 99.602% when pulling 099a4f3 on 0x0a0d:master into 34ebcb4 on icebob:master.

@erfanium erfanium requested a review from icebob December 31, 2020 09:54
Copy link
Owner

@icebob icebob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test which covers the original problem

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

Successfully merging this pull request may close these issues.

3 participants