本文整理匯總了PHP中Illuminate\Contracts\Validation\Validator::fails方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::fails方法的具體用法?PHP Validator::fails怎麽用?PHP Validator::fails使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Contracts\Validation\Validator
的用法示例。
在下文中一共展示了Validator::fails方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: messages
/**
* Returns validation errors, if any
*
* @return MessageBag
*/
public function messages()
{
if (is_null($this->validator)) {
$this->validate();
}
if (!$this->validator->fails()) {
return App::make(MessageBag::class);
}
return $this->validator->messages();
}
示例2: messages
/**
* Returns validation errors, if any
*
* @return \Illuminate\Contracts\Support\MessageBag
*/
public function messages()
{
if (is_null($this->validator)) {
$this->validate();
}
if (!$this->validator->fails()) {
return app('\\Illuminate\\Support\\Messagebag');
}
return $this->validator->messages();
}
示例3: validate
public function validate()
{
if ($this->validator->fails()) {
$messages = [];
foreach ($this->validator->messages()->all("The :key variable is not defined or invalid") as $var => $message) {
$messages[] = $message;
}
$msg = 'The .env file has some problems. Please check config/laravel-env-validator.php' . PHP_EOL . implode(PHP_EOL, $messages);
throw new Exception($msg);
}
}
示例4: fails
/**
* Does validation fails with given data
*
* @return bool
* @throws \Exception
*/
public function fails()
{
if (is_null($this->validated)) {
throw new \Exception("No data has been validated yet");
}
return $this->validated->fails();
}
示例5: isValid
/**
* Check if the form is valid
*
* @return bool
*/
public function isValid()
{
if (!$this->validator) {
$this->validate();
}
return !$this->validator->fails();
}
示例6: validateWith
/**
* Run the validation routine against the given validator.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
* @param \Illuminate\Http\Request|null $request
* @return void
*/
public function validateWith($validator, Request $request = null)
{
$request = $request ?: app('request');
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
}