mercredi 21 septembre 2016

Lumen 5.3: How to extend validation class

Validation class has a couple of functions to retrieve errors, how can I extend this class to manipulate array structure of error messages:

$v = Validatior::make($input, $rules);
if($v->fails()){
    // Instead of
    print_r($v->errors()->messages());
    // Have
    print_r($v->getErrorsWithMyPreferedStructure());
}

I want to add my own function to validation class. Obviousely one of the possible solutions is extending validation class and ... But it's not what I'm searching for. I'm looking for a way to extend validation class via it's own methods, if any!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire