feat: Validator에 stringArrray, int, float 추가
This commit is contained in:
@@ -54,6 +54,56 @@ class Validator extends \Valitron\Validator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that a field is an string array
|
||||||
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validateStringArray($field, $value)
|
||||||
|
{
|
||||||
|
if(!is_array($value)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach($value as $subItem){
|
||||||
|
if(!is_string($subItem)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that a field is an integer value
|
||||||
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validateInt($field, $value)
|
||||||
|
{
|
||||||
|
if(!is_int($value)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that a field is an float value
|
||||||
|
*
|
||||||
|
* @param string $field
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validateFloat($field, $value)
|
||||||
|
{
|
||||||
|
if(!is_float($value)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 문자열의 '최대 너비'를 확인함. mb_strwidth 기반
|
* 문자열의 '최대 너비'를 확인함. mb_strwidth 기반
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user