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

Custom validator not called on root schemas #137

Closed
mihaispataru opened this issue May 13, 2020 · 1 comment
Closed

Custom validator not called on root schemas #137

mihaispataru opened this issue May 13, 2020 · 1 comment

Comments

@mihaispataru
Copy link

Hi,

i've come across an issue with the custom validator on root object schemas.

The custom validator is not handled when we create a root object schema.

const schemaRoot = {
  type: 'object',
  $$root: true,
  props: {
    prop1: { type: 'string', optional: true },
    prop2: { type: 'string', optional: true },
  },
  custom: (v, errors, schema, object) => {
    console.log(v, errors, schema, object);
    return v;
  }
};

The result when validating the schema is:

--------------------
ROOT object test
--------------------

Data: { prop1: '' }
Schema: {
  type: 'object',
  '$$root': true,
  props: {
    prop1: { type: 'string', optional: true },
    prop2: { type: 'string', optional: true }
  },
  custom: [Function: custom]
}
Validate Result: true

I've created a repl.it repository with test demo.

Repl.it Demo

@icebob icebob closed this as completed in 68967e9 May 13, 2020
@icebob
Copy link
Owner

icebob commented May 13, 2020

Fix is released in 1.4.1

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

2 participants