Commit Graph

72 Commits

Author SHA1 Message Date
Miroslav Bajtoš 65fa7a1c00 validations: include more details in `err.message`
Modify ValidationError constructor to include the model name and
a human-readable representation of the validation errors (messages)
in the error message.

Before this change, the message was pointing the reader
to `err.details`.  Most frameworks (e.g. express, mocha) log only
`err.message` but not other error properties, thus the logs were
rather unhelpful.

Example of the new error message:

    The `User` instance is not valid. Details: `name` can't be blank.
2014-05-27 21:59:21 -07:00
Miroslav Bajtoš 05410d56e1 validations: include more details in `err.message`
Modify ValidationError constructor to include the model name and
a human-readable representation of the validation errors (messages)
in the error message.

Before this change, the message was pointing the reader
to `err.details`.  Most frameworks (e.g. express, mocha) log only
`err.message` but not other error properties, thus the logs were
rather unhelpful.

Example of the new error message:

    The `User` instance is not valid. Details: `name` can't be blank.
2014-05-20 11:00:19 +02:00
Miroslav Bajtoš 2a74bdc4de validations: support multi-key unique constraint
Modify the "unique" validator to accept additional property names to
narrow the space of rows searched for duplicates.

Example:

Consider `SiteUser` belongsTo `Site` via `siteId` foreign key.
Inside every site, the user email must be unique. It is allowed to
register the same email with multiple sites.

    SiteUser.validateUniquenessOf('email', { scopedTo: ['siteId'] });
2014-05-15 09:15:44 +02:00
crandmck 1db35cc926 Update JSDoc comments with content from api-model.md 2014-05-14 18:30:42 -07:00
crandmck aa11aad298 Fix some small errors 2014-03-13 16:26:29 -07:00
crandmck 9c2098cd35 Updates to JSDoc comments for API doc 2014-03-12 16:28:46 -07:00
Raymond Feng 2b8c1ebaee Reformat the code 2014-01-24 09:09:53 -08:00
Miroslav Bajtos b5e0035d73 Improve properties of ValidationError
- change `statusCode` from 400 to 422
- nest `context` and `codes` inside `details`
- add `details.messages`
- reword the main error message

Remove the call to Error's constructor from ValidationError constructor,
because it's a no-op - Error's constructor creates a new
instance when called via `.call()`.
2013-12-02 21:35:47 +01:00
Raymond Feng f4d62e54e6 Add error stack trace for ValidationError
The issue was initially reported by SLA-370.
2013-09-09 10:12:12 -07:00
Ritchie Martori 008b406dd7 model.find => model.findById, model.all => model.find 2013-06-24 12:42:58 -07:00
Raymond Feng dd8512bc1f Refactor more functions into mixins 2013-05-27 22:20:43 -07:00
Anatoliy Chakkaev 4c717e4335 Fail uniqueness check in case of db error 2013-05-17 09:01:29 -07:00
Raymond Feng 630b991d1d Refactor the CRUD operations to DataAccessObject 2013-05-17 08:49:57 -07:00
Anatoliy Chakkaev 06641da2c6 Add context info to validation error 2013-05-13 22:04:29 -07:00
Anatoliy Chakkaev 136ea91fbf Organize model.js 2013-05-13 22:04:28 -07:00
Anatoliy Chakkaev 3a355851b6 ValidationError instead Error 2013-04-04 19:31:07 +04:00
Anatoliy Chakkaev be17763eca Return valid in case of sync validations 2013-04-01 20:13:55 +04:00
Anatoliy Chakkaev b0a1ed3bed Fix validation issue 2013-04-01 20:08:22 +04:00
Anatoliy Chakkaev 6449f1ca72 Fix validations 2013-03-31 13:41:02 +04:00
Anatoliy Chakkaev 5540750626 Validation amends
- rename event
- pass data to hooks
- always call hooks (even when no validations set up)
2013-03-28 15:29:11 +04:00
Anatoliy Chakkaev d5d07d8806 Make tests importable 2013-03-26 04:41:00 +04:00
Anatoliy Chakkaev 2fa07e8e1d Rename essentials 2013-03-25 01:27:36 +04:00