php - What is the CORE logic/how they code the "required" built in validation rule of laravel -
i wanna know how code "required" validation rule of laravel.
i tried add required rule input doesnt exist , "required" rule run if changed other rule "email" or etc doesnt runs. im curious.
what mean input doesnt exist exist disyplay:none.
i wanna see function logic.
heres sample code
$validator->sometimes("mmad_bonus_type", 'required', function($input){ return $input->mmad_bonus_type == null; });
the code in validaterequired function of illuminate/validation/validator.php (which in vendor/laravel/framework/src directory).
protected function validaterequired($attribute, $value) { if (is_null($value)) { return false; } elseif (is_string($value) && trim($value) === '') { return false; } elseif ((is_array($value) || $value instanceof countable) && count($value) < 1) { return false; } elseif ($value instanceof file) { return (string) $value->getpath() != ''; } return true; }
Comments
Post a Comment