本文整理汇总了PHP中Respect\Validation\Validator::attribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::attribute方法的具体用法?PHP Validator::attribute怎么用?PHP Validator::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::attribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_findMessages_should_apply_templates_to_flattened_messages
public function test_findMessages_should_apply_templates_to_flattened_messages()
{
$stringMax256 = v::string()->length(5, 256);
$alnumDot = v::alnum('.');
$stringMin8 = v::string()->length(8, null);
$v = v::allOf(v::attribute('first_name', $stringMax256)->setName('First Name'), v::attribute('last_name', $stringMax256)->setName('Last Name'), v::attribute('desired_login', $alnumDot)->setName('Desired Login'), v::attribute('password', $stringMin8)->setName('Password'), v::attribute('password_confirmation', $stringMin8)->setName('Password Confirmation'), v::attribute('stay_signedin', v::notEmpty())->setName('Stay signed in'), v::attribute('enable_webhistory', v::notEmpty())->setName('Enabled Web History'), v::attribute('security_question', $stringMax256)->setName('Security Question'))->setName('Validation Form');
try {
$v->assert((object) array('first_name' => 'fiif', 'last_name' => null, 'desired_login' => null, 'password' => null, 'password_confirmation' => null, 'stay_signedin' => null, 'enable_webhistory' => null, 'security_question' => null));
} catch (ValidationException $e) {
$messages = $e->findMessages(array('allOf' => 'Invalid {{name}}', 'first_name.length' => 'Invalid length for {{name}} {{input}}'));
$this->assertEquals($messages['allOf'], 'Invalid Validation Form');
$this->assertEquals($messages['first_name_length'], 'Invalid length for "fiif" fiif');
}
}
示例2: validateBeforeSave
public function validateBeforeSave()
{
$sessionValidator = v::attribute('sessionId', v::string()->length(1, 32))->attribute('userId', v::string()->length(1, 34))->setName('SessionValidator');
try {
$sessionValidator->assert($this);
return Message::SUCCESS;
} catch (\Exception $ex) {
if (method_exists($ex, 'findMessages')) {
$result = $ex->findMessages(array('sessionId', 'userId'));
return $result;
}
return Message::ERROR_VALIDATION_FAILED;
}
}
示例3: getValidationRules
protected function getValidationRules()
{
v::with('app\\Models\\Validation\\');
return [v::attribute('name', v::notEmpty()->alpha()->length(2, 100)->UniqueDimensionUOMName()), v::attribute('symbol', v::notEmpty()->alpha()->length(2, 2)->UniqueDimensionUOMSymbol()), v::attribute('routeTransaction', v::instance('app\\Models\\RouteTransaction')), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())];
}
示例4: validate
private function validate()
{
try {
$validator = v::attribute('merchantAlias', v::stringType()->alnum('_')->noWhitespace()->length(1, 30))->attribute('macKey', v::stringType()->length(1))->attribute('transactionCode', v::stringType()->alnum()->noWhitespace()->length(1, 30))->attribute('requestType', v::oneOf(v::stringType()->equals(self::REQUEST_TYPE_FIRST_ATTEMPT), v::stringType()->equals(self::REQUEST_TYPE_RETRY_ATTEMPT)))->attribute('operationId', v::stringType()->digit()->noWhitespace()->length(1, 10))->attribute('operationType', v::oneOf(v::stringType()->equals(self::OPERATION_TYPE_CAPTURE), v::stringType()->equals(self::OPERATION_TYPE_VOID)))->attribute('originalAmount', v::stringType()->digit()->noWhitespace()->length(9, 9))->attribute('currency', v::stringType()->alnum()->noWhitespace()->length(3, 3))->attribute('authCode', v::stringType()->alnum()->noWhitespace()->length(1, 10))->attribute('operationAmount', v::stringType()->digit()->noWhitespace()->length(9, 9))->attribute('user', v::optional(v::stringType()->alnum()->length(0, 20)))->attribute('isTest', v::boolType());
$validator->assert($this);
} catch (NestedValidationException $e) {
throw new ValidationException($e->getFullMessage());
}
}
示例5: isValid
/**
* @return boolean
* @param stdClass $user
*/
public function isValid($user)
{
$userValidator = v::attribute('ID', v::numeric())->attribute('USUARIO', v::string()->notEmpty()->noWhitespace())->attribute('NOME', v::string()->notEmpty())->attribute('EMAIL', v::email())->attribute('CPF', v::cpf())->attribute('STATUS', v::numeric())->attribute('UNIDADES', v::arr());
return $userValidator->validate($user);
}
示例6: getValidationRules
protected function getValidationRules()
{
return [v::attribute('name', v::notEmpty()->alpha()->length(2, 100)), v::attribute('symbol', v::notEmpty()->alpha()->length(2, 2)), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())];
}
示例7: init
public function init()
{
$this->validator = v::attribute('name', v::string()->notEmpty())->attribute('email', v::email())->attribute('description', v::string()->length(5, 50))->attribute('age', v::callback('is_int')->between(0, 100))->attribute('nick', v::string()->alnum()->noWhitespace())->attribute('creditCard', v::numeric()->creditCard())->attribute('accountBalance', v::float())->attribute('banned', v::bool())->attribute('views', v::callback('is_int')->positive());
}
示例8: getValidationRules
protected function getValidationRules()
{
v::with('app\\Models\\Validation\\');
return [v::attribute('provider', v::oneOf(v::instance('app\\Models\\Provider'))), v::attribute('carrier', v::oneOf(v::instance('app\\Models\\Carrier'))), v::attribute('name', v::notEmpty()->length(3, 100)->alpha()->UniqueProviderName()), v::attribute('symbol', v::notEmpty()->length(3, 100)->UniqueProviderSymbol()), v::attribute('routeTransaction', v::instance('app\\Models\\RouteTransaction')), v::attribute('statusId', v::notEmpty()->int()->positive()), v::attribute('createdAt', v::notEmpty()->date()), v::attribute('expiresAt', v::notEmpty()->date())];
}