Created
March 6, 2015 16:34
-
-
Save damianoporta/98debb1f6e9c82b68dcd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function validationProfile(Validator $validator) | |
{ | |
$validator | |
>requirePresence('username') | |
->notEmpty('username') | |
->add('username', [ | |
'uniqueEmail' => [ | |
'rule' => ['validateUnique', [/*'scope' => 'site_id'*/]], | |
'provider' => 'table', | |
'message' => 'Email già registrata!', | |
'on' => function ($context) { | |
return (empty($context['data']['_username'])) || ($context['data']['username'] !== $context['data']['_username']); | |
} | |
], | |
'emailFormat' => [ | |
'rule' => 'email', | |
'message' => 'Formato email non valido', | |
] | |
]) | |
->requirePresence('username_repeat') | |
->notEmpty('username_repeat', 'Campo obbligatorio') | |
->add('username_repeat', 'usernameRepeat', [ | |
'rule' => ['compareWith', 'username'], | |
'message' => 'L\'email non coincide', | |
'on' => function ($context) { | |
return (empty($context['data']['_username'])) || ($context['data']['username'] !== $context['data']['_username']); | |
} | |
]) | |
->notEmpty('password_repeat', 'Campo obbligatorio') | |
->add('password', 'passwordLength', [ | |
'rule' => ['minLength', 3], | |
'message' => 'Campo obbligatorio', | |
]) | |
->notEmpty('password_repeat', 'Campo obbligatorio') | |
->add('password_repeat', 'passwordRepeat', [ | |
'rule' => ['compareWith', 'password'], | |
'message' => 'La password non coincide', | |
]); | |
return $validator; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment