Welcome Guest, Not a member yet? Register   Sign In
Custom Validation Rule in Model
#6

(01-22-2021, 05:54 PM)josh2112o Wrote: Hi,
Thanks for the links...
So I have this code in my model for validation:
PHP Code:
protected $validationRules = [
 
'day_walked' => 'trim|required|is_unique[walking_stats.day_walked]',
'cal_burned' => 'trim|required|decimal|greater_than[0]',
'miles_walked' => 'trim|required|decimal|greater_than[0]',
'duration' => 'trim|required|exact_length[8]|durationFormat(duration)|durationFormatValues(duration)|durationZeroError(duration)',
'mph' => 'trim|required|decimal|greater_than[0]',
  ]; 

Say for the
PHP Code:
durationFormat(duration
rule, if I have that function called out in the public $ruleSets array in the Config/Validation.php file which is written in my app/Validation/WalkValidationRules.php file, can I access that function and other's in in my model?

Sorry, I still don't understand what you want  Blush
Can you explain in more detail with an example?

If you need to access the durationFormat() method in the model, then simply create an instance of the WalkValidationRules class.

PHP Code:
$wvr = new \App\Validation\WalkValidationRules();
$wvr->durationFormat(); 
Reply


Messages In This Thread
Custom Validation Rule in Model - by josh2112o - 01-22-2021, 03:28 AM
RE: Custom Validation Rule in Model - by iRedds - 01-22-2021, 02:23 PM
RE: Custom Validation Rule in Model - by iRedds - 01-22-2021, 05:26 PM
RE: Custom Validation Rule in Model - by iRedds - 01-22-2021, 09:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB