mardi 8 mai 2018

Laravel. How to share data between rules?

I am using Laravel and Validation class and i was wondering if is it possible to share data between rules. For example, if i do:

$validator = Validator::make($request->json()->all(), [
      'account' => ['required', new IsAccount, 'bail', new IsActive],
]);

can i use in my custom rule IsActive a property defined by previous IsAccount? I think probably is possible because essentially validator is a class so i just have to set a property, but is it a good practice? and what is the best way to do it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wjvXN2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire