本文整理汇总了PHP中Validator::allErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::allErrors方法的具体用法?PHP Validator::allErrors怎么用?PHP Validator::allErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::allErrors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
function validate()
{
$validator = new Validator($this->_value);
if ($this->isRequired()) {
$validator->required(sprintf("%s cannot be blank", $this->getName()));
}
$this->_errors = $validator->allErrors();
return $this->allErrors();
}
示例2: validate
function validate()
{
$errors = parent::validate();
$validator = new Validator($this->_value);
if ($this->_max_length > -1) {
$validator->maxLength($this->_max_length, sprintf("%s must not exceed %d characters", $this->getName(), $this->_max_length));
}
$this->_errors = array_merge($errors, $validator->allErrors());
return $this->allErrors();
}
示例3: validate
function validate()
{
$errors = parent::validate();
$validator = new Validator($this->_value);
if (!$this->isMultiline()) {
$validator->notRegexp("/\n/", sprintf("%s must be only one line", $this->getName()));
}
$this->_errors = array_merge($errors, $validator->allErrors());
return $this->allErrors();
}
示例4: validate
function validate()
{
$errors = parent::validate();
$validator = new Validator($this->_value);
$validator->date(sprintf("%s is not a date", $this->getName()));
if ($this->_min_value) {
$validator->minDate(sprintf("%s is too small", $this->getName()));
}
if ($this->_max_value) {
$validator->maxDate(sprintf("%s is too big", $this->getName()));
}
if ($validator->hasErrors()) {
$this->_errors = array_merge($errors, $validator->allErrors());
}
return $this->allErrors();
}
示例5: validate
function validate()
{
$errors = parent::validate();
$validator = new Validator($this->_value);
if ($this->_decimal) {
$validator->float(sprintf("%s must be a number", $this->getName()));
} else {
$validator->integer(sprintf("%s must be a number", $this->getName()));
}
if ($this->_min_value) {
$validator->min($this->_min_value, sprintf("%s must be greater than %f", $this->getName(), $this->_min_value));
}
if ($this->_max_value) {
$validator->max($this->_max_value, sprintf("%s must be less than %f", $this->getName(), $this->_max_value));
}
$this->_errors = array_merge($errors, $validator->allErrors());
return $this->allErrors();
}
示例6: validate
function validate()
{
$errors = parent::validate();
$validator = new Validator($this->_value);
if (is_array($data) && !$this->isMultiple()) {
$errors[] = sprintf("only choose one value for %s", $this->getName());
} elseif (is_array($data) && $this->isMultiple()) {
foreach ($data as $item) {
$validator->setValue($item);
$validator->oneOf($this->getChoices(), sprintf("'%s' is an unknown choice for %s", $item, $this->getName()));
}
} else {
$validator->oneOf($this->getChoices(), sprintf("'%s' is an unknown choice for %s", $item, $this->getName()));
}
if ($validator->hasErrors()) {
$this->_errors = array_merge($errors, $validator->allErrors());
}
return $this->allErrors();
}