(req: AxeRequest, model: IModelService, formData: any)
| 14 | }); |
| 15 | } |
| 16 | async validate(req: AxeRequest, model: IModelService, formData: any) { |
| 17 | // Setting the language |
| 18 | Validator.useLang(req.currentLanguage.language); |
| 19 | |
| 20 | // Getting the validation rules |
| 21 | const requestMethod: HttpMethods = req.method as unknown as HttpMethods; |
| 22 | const validationRules = model.instance.getValidationRules(requestMethod); |
| 23 | |
| 24 | // Validating the data if there is any |
| 25 | if (validationRules) { |
| 26 | const validation = new Validator(formData, validationRules); |
| 27 | |
| 28 | // Return the validation errors |
| 29 | if (validation.fails()) { |
| 30 | return validation.errors; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | return null; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | export default Validatorjs; |
no test coverage detected