Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Value not passed to custom validator if nested validation #349

Open
waterbrookbespoke opened this issue Jun 8, 2021 · 0 comments
Open

Comments

@waterbrookbespoke
Copy link

Custom validator:

_customValidator() {
       validate.validators.custom = function (value, options, key, attributes) {
           console.log(sprintf("Custom validation %s value: %s", key, value));
           console.log("Custom validation %s options: %s",key, options);
           console.log("Custom validation %s attributes: %s", key, JSON.stringify(attributes));

           return "is totally wrong";
       };
   },

Console Log:
// Value passed correctly for single level validation
Custom validation lastname value: Flintstone
Custom validation lastname options: true
Custom validation lastname attributes: {"firstname":"","lastname":"Flintstone","":{},"names":[{"firstname":"Barney","lastname":"Rubble"},{"firstname":"Wilma","lastname":"Flintstone"}]}

// Value undefined for nested validation
Custom validation names.lastname value: undefined
Custom validation names.lastname options: true
Custom validation lastname attributes: {"firstname":"","lastname":"Flintstone","":{},"names":[{"firstname":"Barney","lastname":"Rubble"},{"firstname":"Wilma","lastname":"Flintstone"}]}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant