laravel-validation

how to pass custom validation message to cviebrock/image-validator in laravel?

廉价感情. 提交于 2020-01-15 05:00:07
问题 I am using cviebrock for validating image size in laravel. And thats working fine. But I want to customize the error message. I created an array of message $messages = array( 'image-size' => 'My custome message.', ); and passed to $validation = Validator::make(array($file => $fileObj), array($file => $rules), $messages); But thats not working. -Thanks Arun 回答1: You're using the wrong name, it should be with an underline, like $messages = array( 'image_size' => 'My custome message.', ); 来源:

laravel validation rule max:value not working with variables

南楼画角 提交于 2020-01-06 18:32:47
问题 i’m a newby in laravel , i’m trying to validate a certain field from my input request using the max:value rule , the thing is that the value is neither a static value nor a field in my request input , its a value that i retrieve from my database and stored in a variable $available , whenever i try ( ‘count’ => required|numeric|max:$available ) the validation always fails on max as if it cannot evaluate that variable $available , however when i try to use a static value which is not the case

laravel validation rule max:value not working with variables

让人想犯罪 __ 提交于 2020-01-06 18:32:13
问题 i’m a newby in laravel , i’m trying to validate a certain field from my input request using the max:value rule , the thing is that the value is neither a static value nor a field in my request input , its a value that i retrieve from my database and stored in a variable $available , whenever i try ( ‘count’ => required|numeric|max:$available ) the validation always fails on max as if it cannot evaluate that variable $available , however when i try to use a static value which is not the case

How to prevent insert email if already exist with specific id in laravel?

落爺英雄遲暮 提交于 2019-12-29 09:06:11
问题 I have table in which i'm trying to store email addresses. These email addresses will be save with user_id . For example in email_list table |ID | user_id | email | ............................... | 1 | 101 | john@gmail.com | ............................... | 2 | 102 | john@gmail.com | In above table you can see same email addresses save with different user_id , that's it what i'm trying to do. Currently i'm trying simple laravel validation like this. 'email' => 'required|unique:email_list

Required field only if another field has a value, must be empty otherwise

江枫思渺然 提交于 2019-12-23 10:17:36
问题 My question is about Laravel validation rules. I have two inputs a and b . a is a select input with three possible values: x , y and z . I want to write this rule: b must have a value only if a values is x . And b must be empty otherwise. Is there a way to write such a rule? I tried required_with , required_without but it seems it can not cover my case. In other words, if the previous explanation was not clear enough: If a == x , b must have a value. If a != x , b must be empty. 回答1: You have

Laravel 5 __construct() argument passing error

风流意气都作罢 提交于 2019-12-22 12:27:09
问题 So I am trying to group all my validation rules into its respective files in folders for easy maintenance. Below is how my folder structures look: Project --app --config --(more folders) --domains ----App --------Entities --------Repositories --------Services --------Validators ----Core --------Validators So what I wanted to achieve is under Core\Validators I created a LaravelValidator.php which look like this <?php namespace Core\Validators; use Validator; abstract class LaravelValidator { /

Laravel validation OR

拜拜、爱过 提交于 2019-12-21 05:16:21
问题 I have some validation that requires a url or a route to be there but not both. $this->validate($request, [ 'name' => 'required|max:255', 'url' => 'required_without_all:route|url', 'route' => 'required_without_all:url|route', 'parent_items'=> 'sometimes|required|integer' ]); I have tried using required_without and required_without_all however they both get past the validation and I am not sure why. route is a rule in the route field 回答1: I think the easiest way would be creation your own

Laravel Validation: required_with_all condition always passing

独自空忆成欢 提交于 2019-12-20 01:40:08
问题 As per laravel validation documentation: required_with_all:foo,bar,... The field under validation must be present only if all of the other specified fields are present. Here is my test: Route::get('/test/{param}', function($param) { $screenRules = array( 'foo' => 'string', 'param' => 'required_with_all:foo', ); $validator = Validator::make(array('param' => $param), $screenRules); if($validator->fails()) { echo '<pre>'; print_r($validator->errors()); echo '</pre>'; die('Dying now!'); } else {

Laravel Extended Validation custom message

天大地大妈咪最大 提交于 2019-12-19 14:05:01
问题 I wanted to create this extended validation. Validator::extend('my_custom_validation_rule', function ($attribute, $value, $parameters) { // I guess I should be setting the error message for this here.(Its dynamic) // We can return true or false here depending upon our need. } I would use this rule like this 'my_field' => 'required|my_custom_validation_rule' , I want to use some dynamic message for the error of " my_custom_validation_rule " I was unable to find something from the documentation

Laravel Extended Validation custom message

混江龙づ霸主 提交于 2019-12-19 14:04:15
问题 I wanted to create this extended validation. Validator::extend('my_custom_validation_rule', function ($attribute, $value, $parameters) { // I guess I should be setting the error message for this here.(Its dynamic) // We can return true or false here depending upon our need. } I would use this rule like this 'my_field' => 'required|my_custom_validation_rule' , I want to use some dynamic message for the error of " my_custom_validation_rule " I was unable to find something from the documentation