本文整理汇总了PHP中Respect\Validation\Validator::positive方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::positive方法的具体用法?PHP Validator::positive怎么用?PHP Validator::positive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Respect\Validation\Validator
的用法示例。
在下文中一共展示了Validator::positive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($prop, $label)
{
$v = $this->getValue($prop);
if (!v::positive()->validate($v)) {
$this->addException("O campo {$label} deve conter um valor positivo");
}
}
示例2: __construct
public function __construct($data)
{
parent::__construct();
$this->data = $data;
$this->fields = array('firstname' => array('value' => $this->data['firstname'], 'validators' => array('notEmpty'), 'errors' => array('Firstname is empty')), 'email' => array('value' => $this->data['email'], 'validators' => array('email', 'notEmpty'), 'errors' => array('Email is not valid', 'Email is empty')), 'url' => array('value' => $this->data['url'], 'validators' => array('notEmpty', 'url'), 'errors' => array('Url is empty', 'Url is not valid')), 'cv' => array('value' => $_FILES['cv'], 'validators' => function () {
return v::exists()->validate($_FILES['cv']["tmp_name"]);
}, 'errors' => array('File is empty')), 'content' => array('value' => $this->data['content'], 'validators' => function ($value) {
return v::when(v::int(), v::positive(), v::notEmpty())->validate($value);
}, 'errors' => array('content is not valid')), 'int' => array('value' => $this->data['int'], 'validators' => function ($value) {
return v::allOf(v::int(), v::positive(), v::notEmpty())->validate($value);
}, 'errors' => array('int is not valid')), 'uppercase' => array('value' => '', 'validators' => function ($value) {
return v::string()->uppercase()->validate($value);
}, 'errors' => array('uppercase is not valid')));
}