Closed chodorowicz closed 8 years ago
The limitation here is with the way I'm flattening the validation errors. Joi handles complex object validation fine.
I think you can get it to work with the following API's:
getValidatorData: function() {
return {
username: this.state.user.profile.username,
password: this.state.user.profile.password
};
}
validatorTypes: {
username: Joi.string().alphanum().min(3).max(30).required(),
password: Joi.string().regex(/[a-zA-Z0-9]{3,30}/)
}
getValidatorData is going to flatten your object to be used by this validation library and validatorTypes will just be a simple Joi schema for the resulting flattened data. This should allow you validate the field and get the resulting validations messages from the api.
Give it a try I think this is currently the way to do this. I am working towards a pretty heavy refactor of this lib that will fix this limitation but I'm not sure when those will be ready; weeks/month not days.
It's working. Thanks! Will be enough until rewrite is ready. Greets!
I'll try to get validation messages for deep object paths in the next release. It didn't make it in my latest release but should not be to much hard to support now.
Cool! :+1:
This has been fixed with 5.2.0: https://github.com/jurassix/react-validation-mixin/releases/tag/v5.2.0
Ensure you upgrade joi-validation-strategy to v0.2.1
Awesome! I will test it out soon!
I'm using nested object to keep state and https://github.com/EarthlingInteractive/react-deep-link-state to link state. Is there a way to make it work?