本文整理匯總了PHP中Valid::equals方法的典型用法代碼示例。如果您正苦於以下問題:PHP Valid::equals方法的具體用法?PHP Valid::equals怎麽用?PHP Valid::equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Valid
的用法示例。
在下文中一共展示了Valid::equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isValid
public function isValid($Validation_data)
{
$errors = [];
foreach ($Validation_data as $name => $value) {
if (isset($_REQUEST[$name])) {
$exploded = explode(':', $value);
switch ($exploded[0]) {
case 'min':
$min = $exploded[1];
if (Valid::string()->length(3)->validate($_REQUEST[$name]) == false) {
$errors[] = "{$name} must be {$min} caracters long";
}
break;
case 'email':
if (Valid::email()->validate($_REQUEST[$name]) == false) {
$errors[] = $name . ' is not a valid email';
}
break;
case 'equalsTo':
$field = $exploded[1];
if (!Valid::equals($name)->validate($field)) {
$errors[] = $name . " must be equal to " . $field;
}
break;
}
}
}
return $errors;
}
示例2: test_equals
/**
* Tests Valid::equals()
*
* @test
* @dataProvider provider_equals
* @param string $string value to check
* @param integer $required required value
* @param boolean $correct is $string the same as $required?
* @return boolean
*/
public function test_equals($string, $required, $correct)
{
return $this->assertSame($correct, Valid::equals($string, $required), 'Values are not equal');
}