app/library/Validation/Validator/Alpha.php: update to phalcon4 api.
This commit is contained in:
parent
0971f8f35e
commit
bb12b1a007
1 changed files with 8 additions and 8 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
namespace Httpcb\Validation\Validator;
|
namespace Httpcb\Validation\Validator;
|
||||||
|
|
||||||
use Phalcon\Validation\Message;
|
use Phalcon\Validation\Message;
|
||||||
use Phalcon\Validation\Validator as BaseValidator;
|
use Phalcon\Validation\AbstractValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The same as the default Alpha validator shipped with phalcon.
|
* The same as the default Alpha validator shipped with phalcon.
|
||||||
|
|
@ -12,16 +12,16 @@ use Phalcon\Validation\Validator as BaseValidator;
|
||||||
*
|
*
|
||||||
* @package Validation\Validator
|
* @package Validation\Validator
|
||||||
*/
|
*/
|
||||||
class Alpha extends BaseValidator
|
class Alpha extends AbstractValidator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Executes the validation
|
* Executes the validation
|
||||||
*
|
*
|
||||||
* @param mixed $validation
|
* @param mixed $validation
|
||||||
* @param string $attribute
|
* @param string $field
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function validate(\Phalcon\Validation $validation, $attribute)
|
public function validate(\Phalcon\Validation $validation, $field) : bool
|
||||||
{
|
{
|
||||||
$allowSpace = $this->getOption('allowSpace', false);
|
$allowSpace = $this->getOption('allowSpace', false);
|
||||||
|
|
||||||
|
|
@ -30,13 +30,13 @@ class Alpha extends BaseValidator
|
||||||
$charlist .= '[:space:]';
|
$charlist .= '[:space:]';
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = $validation->getValue($attribute);
|
$value = $validation->getValue($field);
|
||||||
|
|
||||||
if (preg_match("/[^{$charlist}]/imu", $value)) {
|
if (preg_match("/[^{$charlist}]/imu", $value)) {
|
||||||
|
|
||||||
$label = $this->getOption('label');
|
$label = $this->getOption('label');
|
||||||
if (empty($label)) {
|
if (empty($label)) {
|
||||||
$label = $validation->getLabel($attribute);
|
$label = $validation->getLabel($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = $this->getOption('message');
|
$message = $this->getOption('message');
|
||||||
|
|
@ -48,12 +48,12 @@ class Alpha extends BaseValidator
|
||||||
|
|
||||||
$code = $this->getOption("code");
|
$code = $this->getOption("code");
|
||||||
if (is_array($code)) {
|
if (is_array($code)) {
|
||||||
$code = $code[$attribute];
|
$code = $code[$field];
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = str_replace(array_keys($replace), $replace, $message);
|
$message = str_replace(array_keys($replace), $replace, $message);
|
||||||
|
|
||||||
$msg = new Message($message, $attribute, "Alpha", $code);
|
$msg = new Message($message, $field, "Alpha", $code);
|
||||||
$validation->appendMessage($msg);
|
$validation->appendMessage($msg);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Reference in a new issue