@@ -6,34 +6,40 @@ trait ValidatorTrait
66{
77 /**
88 * Calls the validator instance to validate
9- * Also runs the beforeValidation and afterValidation methods if exists
9+ * Also runs the beforeValidation and afterValidation methods if exists.
1010 */
1111 public function validate ()
1212 {
1313 // Runs the logic that might be executed before the model validation
14- if (method_exists ($ this , 'beforeValidation ' )) $ this ->beforeValidation ();
14+ if (method_exists ($ this , 'beforeValidation ' )) {
15+ $ this ->beforeValidation ();
16+ }
1517
1618 // Model validation
1719 (new ModelValidator ($ this ))->validate ();
1820
1921 // Runs the logic that might be executed after the model validation
20- if (method_exists ($ this , 'afterValidation ' )) $ this ->afterValidation ();
22+ if (method_exists ($ this , 'afterValidation ' )) {
23+ $ this ->afterValidation ();
24+ }
2125 }
22-
26+
2327 /**
24- * Alias method for calling the validate method on saving the model
28+ * Alias method for calling the validate method on saving the model.
2529 */
26- public static function validateOnSaving () {
27- static ::saving (function ($ model ){
30+ public static function validateOnSaving ()
31+ {
32+ static ::saving (function ($ model ) {
2833 $ model ->validate ();
2934 });
3035 }
3136
3237 /**
33- * Alias method for calling the validate method on creating the model
38+ * Alias method for calling the validate method on creating the model.
3439 */
35- public static function validateOnCreating () {
36- static ::creating (function ($ model ){
40+ public static function validateOnCreating ()
41+ {
42+ static ::creating (function ($ model ) {
3743 $ model ->validate ();
3844 });
3945 }
0 commit comments