Search code examples
laravellaravel-validation

how can i define rule for unique email in laravel RuleFactory


    $this->_rulesFactory = new RulesFactory(
        new RuleExtensionRegistry(),
        $this->_errorTemplateRegistry,
        new Compiler()
    );

    $this->_validator = new Validator($this->_rulesFactory);

    $this->_validator->field('email')->required()->email("uniqe");

I used this code and getting this error in the postman

"message": "No rule extension with name \"uniqe\" exists",

Solution

  • You need to mention the table name, from where you want to check the email.

    $this->_validator->field('email')->required()->email("uniqe:table_name");