vendredi 26 février 2016

Laravel Validation - Best practices with Request classes

Laravel (currently 5.2) says

For more complex validation scenarios, you may wish to create a "form request". Form requests are custom request classes that contain validation logic.

I have this all implemented, but now I need to import some data that is not coming through HTTP, but from an uploaded document.

Is there an easy way to manually validate data using the rules set in the Request classes, or is there a standardised Laravel way of separating the rules so that they can be used in multiple places?

Note: I have different rules for storing and updating etc

One approach I thought of was to create some static properties on my models, eg. User::$storeRules etc.

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire