Closed ivan-kleshnin closed 9 years ago
Thanks for breaking this out separately. I hope to work on this after issue #3 is resolved.
I'm not sure this library is going to support introspection of the user form. I'm closing this issue as there is currently no like functionality in this library. I feel that a consumer of this library can add this abstraction easily and produce a tool/library with these features.
To recap
Messages like "serialNumber must be a number" are not very friendly. Joi provides an option to override key name in message with label method.
But you, probably, have already defined that labels in your form declaration and don't want to repeat it again. To manually handle this it's possible to make validatorTypes a function and access field labels by this.refs.
It's a bit more in-sync, but even more verbose :(
It's really verbose so my suggestion was to add
autoLabel
propety which could automate this tedious label passing.The one of possible alternatives I considered is tweaking
validatorTypes
return type:I like first approach more because it decouples one task from another.
validatorTypes
is already complex enough (accounting it can be map, function... – requires a lot of documentation already).Name
autoLabel
is probably too generic. Even native React methods are longer (shouldComponentUpdate
...). So now I think it's better to call itautoLabelValidations
or evenautoLabelValidationMessages
.Do you have ideas how this auto-labeling may be implemented differently?