Closed fbaiodias closed 9 years ago
Yes this is confusing and I didn't document very well either.
There were some compromises I had to make around getValidationMessages
in order to support validating nested objects and object arrays. Basically, it was difficult to rehydrate the errors object.
The current implementation should return a single error when multiple exist (compromise) and should only return an array if the joi data structure was an array.
Related Issues:
If you would like to take a stab at this that would be greatly appreciated. The test coverage is pretty good for this library, so that will definitely help.
Alright, thanks for the quick reply!
Will look into it then :)
This was the compromise, and a good place to start looking for improvements:
https://github.com/jurassix/joi-validation-strategy/blob/master/src/joiValidationStrategy.js#L28
By doing this I believe it helped me maintain the original structure of the error object. Before this method would always guarantee an array of errors.
Resolved in the following version:
react-validation-mixin v5.3.1 joi-validation-strategy v0.3.0
Hey!
First of all, thanks for making this module. It's great and very useful!
However, I'm finding the changes introduced in v5.2.0 on
getValidationMessages
a bit confusing.For example, if
propA
has two errors, and you dothis.props.getValidationMessages('propA')
, it only returns the first error message as astring
. However, if thepropA
is valid, an emptyarray
is returned instead.I believe it would be clearer if it always returned an
array
as before, or instead returnedundefined
when there are no errors.I would be happy to do a PR if you think this makes sense :)
Cheers