zawsze sprawiało mi to problem, nie umiem uruchomić walidacji zawierającej wyrażenie regularne, czy ktoś mógłbym napisać mi jak to powinno być i dlaczego?
wyrażenie regularne: ^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$
prawidłowe dane YYYY-MM-DD np 2019-06-17
Wyrażenie jest prawidłowe, problem stanowi uruchomienie go wewnątrz walidacji od Laravela.
Kod:
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class FiltersRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'date' => 'required|regex:/\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/', // CZESC KTORA NAS INTERESUJE ]; } }