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

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

java - Incorrect order of records in M-M relationship in hibernate -