Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Laravel] Request (Validacja) pole z reqex
KotWButach
post 17.06.2019, 09:44:07
Post #1





Grupa: Zarejestrowani
Postów: 361
Pomógł: 10
Dołączył: 8.02.2012

Ostrzeżenie: (0%)
-----


Witam,
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:

  1.  
  2. <?php
  3.  
  4. namespace App\Http\Requests;
  5.  
  6. use Illuminate\Foundation\Http\FormRequest;
  7.  
  8. class FiltersRequest extends FormRequest
  9. {
  10. /**
  11.   * Determine if the user is authorized to make this request.
  12.   *
  13.   * @return bool
  14.   */
  15. public function authorize()
  16. {
  17. return true;
  18. }
  19.  
  20. /**
  21.   * Get the validation rules that apply to the request.
  22.   *
  23.   * @return array
  24.   */
  25. public function rules()
  26. {
  27. return [
  28.  
  29. 'date' => 'required|regex:/\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/', // CZESC KTORA NAS INTERESUJE
  30.  
  31. ];
  32. }
  33. }
  34.  
  35.  


Ten post edytował KotWButach 17.06.2019, 09:46:02
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
phamyen
post 25.06.2019, 04:59:03
Post #2





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 14.05.2019

Ostrzeżenie: (10%)
X----


The article you shared here is very awesome. I really like and appreciate your work. I have read your article deeply, the points that you mentioned in this article are useful
girls go games
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 27.04.2024 - 20:40