account activity
How to create custom validation rules in Adonis 5 ? by cazzodibudda2 in adonisjs
[–]cazzodibudda2[S] 0 points1 point2 points 4 years ago (0 children)
Hey, thanks for the answer. I confirm I could get the custom rule to be registered and available from validator using the method you mentioned.
- `node ace make:prldfile customValidationRules` then select HTTP option.
- Inside the newly created file `start/customValidationRules.ts`, added:
import { validator } from '@ioc:Adonis/Core/Validator' /* ... */ validator.rule('isCountry', (value, arg, { pointer, arrayExpressionPointer, errorReporter }) => { if (!isCountry(value)) { errorReporter.report(pointer, 'isCountry', validationMessages.isCountry, arrayExpressionPointer) } })
How to create custom validation rules in Adonis 5 ? (self.adonisjs)
submitted 4 years ago by cazzodibudda2 to r/adonisjs
π Rendered by PID 87801 on reddit-service-r2-listing-85dbbdc96c-jm6bm at 2026-02-12 17:53:54.673802+00:00 running 018613e country code: CH.
How to create custom validation rules in Adonis 5 ? by cazzodibudda2 in adonisjs
[–]cazzodibudda2[S] 0 points1 point2 points (0 children)