Framework: Bug Validation Rules in - The first of given list of values never match

Created on 25 Apr 2017  路  2Comments  路  Source: laravel/framework

  • Laravel Version: 5.4
  • PHP Version: 7.1

Description:

When you try to validate a field must be included in the given list of values. The first value of the array list never match. The validation always returns that the first value of the array list does not match.

Steps To Reproduce:

If you add a new value at the begining of the array, the first one will never match.
'canton' => 'sometimes|required|size:2|in:' . Rule::in(['zh','zg','vs','vd','ur','ti']),

if you change the first value like this :
['fr','zh','zg','vs','vd','ur','ti']

the 'zh' working, but not the first 'fr'

Most helpful comment

If you use the Rule class to define the rule, don't use in: prefix.

https://laravel.com/docs/5.4/validation#rule-in

All 2 comments

If you use the Rule class to define the rule, don't use in: prefix.

https://laravel.com/docs/5.4/validation#rule-in

@bonzai Correct, I do not know how I could miss it ...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anahkiasen picture Anahkiasen  路  3Comments

YannPl picture YannPl  路  3Comments

fideloper picture fideloper  路  3Comments

gabriellimo picture gabriellimo  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments