0

here is input value : FIRST_TIME_ARRIVAL_DATE_AT_DAW : 2016-21-5 17:21:35 here is validation rule :

public static $createRules = [
      'FIRST_TIME_ARRIVAL_DATE_AT_DAW' => 'date_format:"Y-m-d H:i:s"',
];

and it doesn't validatate, it return :

{"CELLS_EXPIRY_DATE":["The FIRST TIME ARRIVAL DATE AT DAW does not match the format Y-m-d H:i:s."]

EDIT: here is what my controller looks like:

$validator = Validator::make($request->all(),BatteryAssets::$createRules);
        if ($validator->fails()) {
            return ['success' => 0, 'data' => 'Input error','errors' => $validator->messages()->toJson()];
        }

so $validator->messages()->toJson() return the validation error

2
  • Which part fails? The actual validation? The custom error message? What does your form look like? Also, is it required? If so, you should add required to the rule. Commented Oct 1, 2016 at 13:51
  • I have added the controller code to my question, so the validation rules are not met, even though it seems that I input the right values, and the field is not required but if present ti has to have the format, the form is just regular input text where I add this value: 2016-21-5 17:21:35 Commented Oct 1, 2016 at 19:01

2 Answers 2

2
format Y-m-d H:i:s need be 2016-21-05 17:21:35
Sign up to request clarification or add additional context in comments.

2 Comments

and that's what my input is 2016-21-5 17:21:35, but for some reason the rule is not met
@Mikail 2016-21-05 not 2016-21-5
0

Change 'date_format:"Y-m-d H:i:s"' to 'date_format:Y-m-d H:i:s'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.