@adonisjs/validator
Advanced tools
Comparing version 6.2.0 to 6.2.1
@@ -10,3 +10,11 @@ "use strict"; | ||
*/ | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ErrorReporters = __importStar(require("../ErrorReporter")); | ||
/** | ||
@@ -18,8 +26,18 @@ * Extends the request class by adding `validate` method | ||
Request.macro('validate', function validateRequest(schema, messages, config) { | ||
/** | ||
* Attempt to find the best error reporter for validation | ||
*/ | ||
let Reporter = ErrorReporters.VanillaErrorReporter; | ||
if (this.accepts(['json']) === 'json') { | ||
Reporter = ErrorReporters.ApiErrorReporter; | ||
} | ||
if (this.accepts(['application/vnd.api+json']) === 'application/vnd.api+json') { | ||
Reporter = ErrorReporters.JsonApiErrorReporter; | ||
} | ||
return validate(schema, { | ||
...this.all(), | ||
...this.allFiles(), | ||
}, messages, config); | ||
}, messages, Object.assign({ reporter: Reporter }, config)); | ||
}); | ||
} | ||
exports.default = extendRequest; |
@@ -61,3 +61,3 @@ "use strict"; | ||
toError() { | ||
return new ValidationException_1.ValidationException(true, this.errors); | ||
return new ValidationException_1.ValidationException(false, this.toJSON()); | ||
} | ||
@@ -64,0 +64,0 @@ /** |
export { ApiErrorReporter } from './Api'; | ||
export { VanillaErrorReporter } from './Vanilla'; | ||
export { JsonApiErrorReporter } from './JsonApi'; |
@@ -15,1 +15,3 @@ "use strict"; | ||
exports.VanillaErrorReporter = Vanilla_1.VanillaErrorReporter; | ||
var JsonApi_1 = require("./JsonApi"); | ||
exports.JsonApiErrorReporter = JsonApi_1.JsonApiErrorReporter; |
@@ -65,3 +65,3 @@ "use strict"; | ||
toError() { | ||
return new ValidationException_1.ValidationException(true, this.errors); | ||
return new ValidationException_1.ValidationException(true, this.toJSON()); | ||
} | ||
@@ -68,0 +68,0 @@ /** |
@@ -25,3 +25,3 @@ "use strict"; | ||
session.flashExcept(['_csrf_token']); | ||
ctx['session'].flash(error.messages); | ||
ctx['session'].flash('errors', error.messages); | ||
ctx.response.redirect('back', true); | ||
@@ -28,0 +28,0 @@ } |
{ | ||
"name": "@adonisjs/validator", | ||
"version": "6.2.0", | ||
"version": "6.2.1", | ||
"description": "Validator for adonis framework", | ||
@@ -5,0 +5,0 @@ "main": "build/providers/ValidatorProvider.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
129093
85
3722
1