tmpfs / async-validate

Asynchronous type validation for node and the browser
Other
314 stars 45 forks source link

Override global default error messages #60

Closed ersefuril closed 8 years ago

ersefuril commented 8 years ago

Please correct me if I'm wrong, documentation is not clear for me on a specific point. I tried to apply your example to override all error messages by custom messages.

So, here is your example :

var Schema = require('async-validate')
  , messages = require('messages-es')
  , descriptor = {
      type: 'object',
      fields: {
        name:{type: "string", required: true}}
      }
    }
  , schema = new Schema(descriptor, {messages: messages});

I tried to clone all default messages and override them. I also tried to define only a small subset of messages to override, still have default error message. Maybe I did a mistake when redefining messages, so you can find a running example here :

https://tonicdev.com/ersefuril/5704d91504d77e13006a864f

tmpfs commented 8 years ago

Thanks, this was actually a bug in the passing of messages to nested schemas, fixed in this commit:

5f6943c089096d148a394de2cf0cb797bb602d55

It is now working as expected as far as I can tell, re-open if you experience more bugs with this.

This fix is in the registry as 0.13.2.

Closing as fixed.

ersefuril commented 8 years ago

Thanks for your fix :)