不要怂,就是干,撸起袖子干!

Commit cab315a3 by Bart Nagel

Renamed model errors key from _ to __model

As discussed on IRC. Also add task for 2.0 to change the validate()
output structure.
1 parent d5b08b4f
...@@ -77,6 +77,9 @@ A very basic roadmap. Chances aren't too bad, that not mentioned things are impl ...@@ -77,6 +77,9 @@ A very basic roadmap. Chances aren't too bad, that not mentioned things are impl
- ~~save datetimes in UTC~~ - ~~save datetimes in UTC~~
- encapsulate attributes if a dao inside the attributes property + add getters and setters - encapsulate attributes if a dao inside the attributes property + add getters and setters
- add proper error message everywhere - add proper error message everywhere
- refactor validate() output data structure, separating field-specific errors
from general model validator errors (i.e.
`{fields: {field1: ['field1error1']}, model: ['modelError1']}` or similar)
## Collaboration 2.0 ## ## Collaboration 2.0 ##
......
...@@ -276,10 +276,10 @@ module.exports = (function() { ...@@ -276,10 +276,10 @@ module.exports = (function() {
try { try {
validator.apply(self) validator.apply(self)
} catch (err) { } catch (err) {
if (!failures.hasOwnProperty('_')) { if (!failures.hasOwnProperty('__model')) {
failures._ = [] failures.__model = []
} }
failures._.push(err.message) failures.__model.push(err.message)
} }
}) })
......
...@@ -330,7 +330,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() { ...@@ -330,7 +330,7 @@ describe(Helpers.getTestDialectTeaser("DAO"), function() {
var failingFoo = Foo.build({ field1: null, field2: null }) var failingFoo = Foo.build({ field1: null, field2: null })
, errors = failingFoo.validate() , errors = failingFoo.validate()
expect(errors).not.toBeNull() expect(errors).not.toBeNull()
expect(errors).toEqual({ '_': ['xor failed'] }) expect(errors).toEqual({ '__model': ['xor failed'] })
var successfulFoo = Foo.build({ field1: 33, field2: null }) var successfulFoo = Foo.build({ field1: 33, field2: null })
expect(successfulFoo.validate()).toBeNull() expect(successfulFoo.validate()).toBeNull()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!