lundi 30 novembre 2015

Laravel Validation between not converting comma separated string to array?

Just trying to do some tags validation. First checking for number of tags (as comma separated list of id's).

class SomePostRequest extends Request
{
    public function rules()
    {
        return [
            'tags' => 'between:2,5'
        ];
    }


    public function all()
    {
        $input = parent::all();

        $input['tags'] = explode(',', @$input['tags']);

        return $input;
    }

}

It keeps spititing out the message as

The tags must be between 2 and 5 characters.

Instead of the proper array message:

The :attribute must have between :min and :max items.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire