gcanti / tcomb-validation

Validation library based on type combinators
MIT License
400 stars 23 forks source link

Default messages #30

Closed benmonro closed 8 years ago

benmonro commented 9 years ago

I'd like the ability to set a default error message in tcomb-validation for certain scenarios. For example, currently the default message that tcomb-validation gives you is 'Invalid value ' + stringify(actual) + ' supplied to ' + to;

Which is fine. But I'd like all required fields to say to + ' is required' without having to specify it in each field. I'm using this w/ tcomb-form and I can set the error message in each field, but it would be much nicer if I could just have all required fields use a default for that condition...

gcanti commented 9 years ago

What about using a getValidationErrorMessage(value, path, context) function https://github.com/gcanti/tcomb-validation#customise-error-messages ?