@adonisjs/validator
Advanced tools
Comparing version 4.0.6 to 4.0.7
@@ -0,1 +1,12 @@ | ||
<a name="4.0.7"></a> | ||
## [4.0.7](https://github.com/adonisjs/adonis-validation-provider/compare/v4.0.5...v4.0.7) (2017-11-17) | ||
### Features | ||
* **exception:** export ValidationException for manual use ([cf5574d](https://github.com/adonisjs/adonis-validation-provider/commit/cf5574d)) | ||
* **formatter:** add support for indicative formatter ([b5284f8](https://github.com/adonisjs/adonis-validation-provider/commit/b5284f8)) | ||
<a name="4.0.6"></a> | ||
@@ -2,0 +13,0 @@ ## [4.0.6](https://github.com/adonisjs/adonis-validation-provider/compare/v4.0.5...v4.0.6) (2017-10-29) |
{ | ||
"name": "@adonisjs/validator", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"description": "Validator for adonis framework", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"@adonisjs/generic-exceptions": "^1.0.0", | ||
"indicative": "^3.0.3", | ||
"indicative": "^3.0.5", | ||
"lodash": "^4.17.4" | ||
@@ -32,3 +32,3 @@ }, | ||
"japa-cli": "^1.0.1", | ||
"nyc": "^11.2.1", | ||
"nyc": "^11.3.0", | ||
"standard": "^10.0.3" | ||
@@ -35,0 +35,0 @@ }, |
@@ -108,3 +108,4 @@ 'use strict' | ||
validatorInstance.rules, | ||
validatorInstance.messages | ||
validatorInstance.messages, | ||
validatorInstance.formatter | ||
) | ||
@@ -111,0 +112,0 @@ |
@@ -22,6 +22,7 @@ 'use strict' | ||
class Validation { | ||
constructor (data, rules, messages) { | ||
constructor (data, rules, messages, formatter) { | ||
this._data = data | ||
this._rules = rules | ||
this._messages = messages | ||
this._formatter = formatter | ||
this._errorMessages = null | ||
@@ -32,5 +33,3 @@ this._executed = false | ||
/** | ||
* Sets the error as a property on instance, if they | ||
* are validation errors. Otherwise an exception | ||
* is thrown | ||
* Sets the error as a property on instance. | ||
* | ||
@@ -44,7 +43,3 @@ * @method _useErrors | ||
_useErrors (errors) { | ||
if (errors instanceof Array === true) { | ||
this._errorMessages = errors | ||
return | ||
} | ||
throw errors | ||
this._errorMessages = errors | ||
} | ||
@@ -79,5 +74,6 @@ | ||
async run () { | ||
this._markAsExecuted() | ||
try { | ||
this._markAsExecuted() | ||
await indicative.validate(this._data, this._rules, this._messages) | ||
await indicative.validate(this._data, this._rules, this._messages, this._formatter) | ||
} catch (error) { | ||
@@ -99,5 +95,6 @@ this._useErrors(error) | ||
async runAll () { | ||
this._markAsExecuted() | ||
try { | ||
this._markAsExecuted() | ||
await indicative.validateAll(this._data, this._rules, this._messages) | ||
await indicative.validateAll(this._data, this._rules, this._messages, this._formatter) | ||
} catch (error) { | ||
@@ -104,0 +101,0 @@ this._useErrors(error) |
@@ -14,2 +14,3 @@ 'use strict' | ||
const Validation = require('../Validation') | ||
const { ValidationException } = require('../Exceptions') | ||
@@ -23,3 +24,5 @@ module.exports = { | ||
sanitizor: indicative.sanitizor, | ||
extend: indicative.extend | ||
formatters: indicative.formatters, | ||
extend: indicative.extend, | ||
ValidationException | ||
} |
26753
12
628
Updatedindicative@^3.0.5