Hi everybody i end of to read the documentation of adonis js for to use "validation rules" but i dont see a option for to validate a "alphanumeric" value(in adonisjs 4.1 this exist but i try to migrate to adonis 5), i have the way of to make this rule but before i need to question ¿Really there not is a alphanumeric validation in validation rules or i need to read the guide again? and ¿there is some platform for ican to send my custom validation rules? Thanks for the answers
Asked
Active
Viewed 418 times
2 Answers
1
Use the regex
helper rule to implement an alphanumeric rule.
From the docs.:
{
username: schema.string({}, [
rules.regex(/^[a-zA-Z0-9]+$/)
])
}
This will allow these:
username10 // --> OK
username // --> OK
Username10 // --> OK
while disallowing these:
user_name // --> BAD
user-name10 // --> BAD
USER@name10 // --> BAD

Amir Hosein Salimi
- 162
- 1
- 10
0
Now there is a rule called alpha
, you can check it out here: https://preview.adonisjs.com/guides/validator/rules#rulesalpha
Or just create a Custom Rule or regex.

elgsantos
- 1,993
- 1
- 5
- 10