Skip to content

Custom Validation Rules #15

Description

@hettiger

Please correct me if I'm wrong with anything written below but ...

I think it is impossible to add custom validation rules when using laracasts/validation.

class LaravelValidator implements FactoryInterface {

    // ...    

    /**
     * @param Validator $validator
     */
    function __construct(Validator $validator)
    {
        $this->validator = $validator;
    }

    // ...
  • You are type hinting Laravel's Validator here which results in a new instance
  • Validator::extend() wont extend laracasts/validation's instance of Validator
  • LaravelValidator is missing an extend() method to get around this

I don't think that I'm doing something wrong because my custom validation rule is working if I do the following in php artisan tinker:

$validator = Validator::make(['test' => 'foo'], ['test' => 'bar']);
$validator->fails();

Is there any other way to extend it easily that I missed? If so an update to the docs would be awesome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions