Laravel 5.1 Date_Format Validator Fails on Y-m-d Format -
i'm starting use request objects validate incoming post data, , i've seen examples of how others using date_format, can't seem dates pass though i'm using format passes when use php's date_parse_from_format:
print_r(date_parse_from_format('y-m-d','2015-07-27'));
output
update: warning in date_parse_from_format, don't understand why reflects format.
{ "year": 2015, "month": 2, "day": 30, "hour": false, "minute": false, "second": false, "fraction": false, "warning_count": 1, "warnings": { "10": "the parsed date invalid" }, "error_count": 0, "errors": [], "is_localtime": false }
validator
public function rules() { return [ 'rental_id' => 'required|exists:rentals,id', 'start_at' => 'required|date_format:y-m-d', 'end_at' => 'required|date_format:y-m-d' ]; }
using postman i'm sending in payload of:
rental_id = 1 text start_at = 2015-02-30 text end_at = 2015-02-30 text
and throws notfoundhttpexception, if comment out start_at , end_at in validator request passes, , enters controllers action proper payload:
{ "rental_id": "1", "start_at": "2015-02-30", "end_at": "2015-02-30" }
apparently, date_format validation failed randomly chose 2015-02-30 test api, day doesn't exist february 30... oh shame , wasted time. @ceejayoz help!!!
Comments
Post a Comment