meteor / validation-error

Standardized validation error format for Meteor
https://atmospherejs.com/mdg/validation-error
Other
12 stars 4 forks source link

Make package compatible with SimpleSchema and Astronomy #7

Closed lukejagodzinski closed 8 years ago

lukejagodzinski commented 8 years ago

Hi @stubailo. We've talked today with @aldeed about SimpleSchema and Astronomy. We've discussed how validation work in SS and A and if the mdg:validation-error package fits our needs. We've came to conclusion that it needs one little change. Instead have the details property per error it's better to keep errors structure plain and keep fields like value, message on the same level as type and name. @aldeed is already using such structure and me too in Astronomy 2.0.

I've also added several improvements that I'm using in Astronomy like:

if (ValidationError.is(err)) {
}

for checking if error is an instance of ValidationError. It's much shorter than:

if (err && err.error === ValidationError.ERROR_CODE) {
}

I've also added possibility to change default error message by overriding static property:

ValidationError.DEFAULT_MESSAGE = 'Validation error';