Closed rostamiani closed 6 years ago
Read the Adonisjs docs, there’s already a unique rule
Thanks. But What do I import to use that rule in indicative? Is there any example?
I am not sure if you have read the docs https://adonisjs.com/docs/4.1/validator#_uniquetablename_fieldname_ignorefield_ignorevalue.
All indicative rules are preloaded in AdonisJs, since it's using the full build
Do I have to import Adonis validator to use unique rule? I'm confused. Should I do it like this? :
rules = { username: [ rule('unique:users') ] }
Or this:
rules = { username: "unique:users'" }
Thanks
Have you even read the AdonisJs docs? If yes, please share the link
I'm using indicative with my Express.js app. This is not an Adonis app then I cannot use Adonis CLI to install validator.
Documentation instructions requires this:
adonis install @adonisjs/validator
This is the information you should told at first. But anyways, you cannot use @adonisjs/validator with express, since it's written specifically for Adonis.
Also the unique
rule relies on the database, so you have to add your own rule based upon the database you are using.
Here's the docs on extend method of indicative https://indicative.adonisjs.com/docs/api/extend
that's my same question and unfortunately this link is no longer working, now, is this: https://indicative.adonisjs.com/validations/master/same
but, don't answer the question how to do a unique rule
I need Unique rule. How can I add it? Or how can I add it using adonis-validator?
Thanks for your perfect module