本文整理汇总了PHP中Illuminate\Validation\Validator::fails方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::fails方法的具体用法?PHP Validator::fails怎么用?PHP Validator::fails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Validation\Validator
的用法示例。
在下文中一共展示了Validator::fails方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate the form data
*
* @param array $formData
* @param null $id
* @throws \BB\Exceptions\FormValidationException
* @return boolean
*/
public function validate(array $formData, $id = null)
{
$this->validation = $this->validator->make($formData, $this->getValidationRules(['id' => $id]));
if ($this->validation->fails()) {
throw new FormValidationException('Validation failed', $this->getValidationErrors());
}
return true;
}
示例2: validate
/**
* Validate the form data
*
* @param array $data
*
* @return mixed
* @throws ValidationException
*/
public function validate(array $data)
{
$this->validation = $this->validator->make($data, $this->getValidationRules(), $this->getValidationMessages());
if ($this->validation->fails()) {
throw new ValidationException('Validation failed', $this->getValidationErrors());
}
return true;
}
示例3: validate
/**
* Validate the given data.
*
* @param array $data
* @return bool
* @throws ValidationException
*/
public function validate(array $data = null)
{
$data = $data ?: $this->getInput();
$this->validation = $this->validator->make($data, $this->rules(), $this->messages());
if ($this->validation->fails()) {
$this->failed();
}
return true;
}
示例4: validate
/**
* @param array $formData
*
* @throws FormValidationException
*/
public function validate(array $formData)
{
// Instantiate validator instance by factory
$this->validation = $this->validator->make($formData, $this->rules());
// Validate
if ($this->validation->fails()) {
throw new FormValidationException('Validation Failed', $this->getValidationErrors());
}
return true;
}
示例5: validate
public function validate()
{
$data = $this->toArray();
$this->validator = Validator::make($data, $this->getSingleValidator());
$result = !$this->validator->fails();
$this->failed = $this->validator->failed();
foreach ($this->getAllValidators() as $key => $validate) {
$validator = Validator::make($data[$key], $validate->getSingleValidator());
$result = !$validator->fails() && $result;
if ($validator->fails()) {
$this->failed = array_merge($this->failed, [$key => $validator->failed()]);
}
}
return $result;
}
示例6: validate
public function validate(\Illuminate\Validation\Validator $validator)
{
if ($validator->fails()) {
$this->validation_errors = $validator->messages();
return false;
}
return true;
}
示例7: validateOrFail
public function validateOrFail($additional = array())
{
$attributes = $this->getAttributes();
$this->validator = \Validator::make($attributes, $this->prepareRules());
if ($this->validator->fails()) {
$messages = $this->validator->messages();
foreach ($attributes as $key => $value) {
if ($messages->has($key)) {
foreach ($messages->get($key) as $message) {
$additional['attribute'] = $key;
$this->errors->add(new Error($message, '', $additional));
}
}
}
throw new ValidationException($this->errors->errors());
}
return true;
}
示例8: validate
/**
* Validate data.
*
* @author Morten Rugaard <moru@nodes.dk>
*
* @return bool
* @throws \Nodes\Validation\Exceptions\ValidationException
*/
public function validate()
{
// Generate validator instance
$this->validator = $this->validatorFactory->make($this->getData(), $this->getRules(), $this->getMessages(), $this->getAttributes());
// Validation was a success!
if (!$this->validator->fails()) {
return true;
}
// Collect validation errors
$this->errors = $this->validator->messages();
return false;
}
示例9: validateData
/**
* Validates the supplied data against the options rules
*
* @param array $data
* @param array $rules
* @param array $messages
*
* @param mixed
*/
public function validateData(array $data, array $rules, array $messages)
{
if ($rules) {
$this->customValidator->setData($data);
$this->customValidator->setRules($rules);
$this->customValidator->setCustomMessages($messages);
//if the validator fails, kick back the errors
if ($this->customValidator->fails()) {
return implode('. ', $this->customValidator->messages()->all());
}
}
return true;
}
示例10: fails
/**
* {@inheritDoc}
*/
public function fails()
{
return $this->validator->fails();
}
示例11: __construct
public function __construct(Validator $validator)
{
if ($validator->fails()) {
parent::__construct(json_encode($validator->errors()->getMessages()));
}
}