mercredi 15 février 2017

Laravel date_format rule not working

I am trying to use a datetime format rule for my input like this:

H:i:s

My model rule looks like this:

    public static $rules = [
        ...
        'start'    => [
            'min:8',
            'date_format:"H:i:s"',
        ],
    ];

And in my controller I call it like this:

        $validator = Validator::make($request->all(), Product::$rules);

        if($validator->fails())
        {
            return Redirect::back()->withInput()->withErrors($validator);
        }

If I dd($validator) I get following:

  #rules: array:7 [▼
     ...
    "start" => array:2 [▼
      0 => "min:8"
      1 => "date_format:"H:i:s""
    ]
  ]

I insert 00:h:01 into the input field but I did not get any error message.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire