mardi 28 février 2017

Laravel 5 - Allow to pass only FormRequest rules fields

I would like to use FormRequest validation in which allow request fields only in rules() return array keys.

In the below code, I would like to allow request fields only 'os', 'number', 'version'. If request include the other field , return error response.

How can I modify the code ?

public function rules()
  {
    return [
        'os' => [
            'required',
            \Rule::in(['android', 'ios']),
        ],
        'number' => 'required|integer',
        'version' => ['required', 'http://regex:/^\d+.\d+.\d+$/'],
    ];
  }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire