Skip to content

Array validation has a problem #2714

Description

@luispastendev

Hello!

I am trying to validate an array structure that comes from my form:

<input type="checkbox" name="category[]" value="id2">
<input type="checkbox" name="category[]" value="id3">
<input type="checkbox" name="category[]" value="id4">

I use the validation library dynamically building the rules for each field which would arrive as category.0, category.1 ...

foreach($data['categorie'] as $key => $value){
    $rules[ 'category.' . $key ] = 'required|alpha|max_length[2]';
}  

validation only works well for all values that have key 1 forwards, but does not correctly identify the field that is in the category.0 position validation fails with "field is required"

 ["category.0"]=>
  string(34) "The categorie.0 field is required.

I have debugged that all the fields get to my controller correctly but it seems to be a validation library error.

thank you very much for your amazing work!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions