mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-22 16:56:50 +01:00
Extract Validator::DATE_FORMAT
This commit is contained in:
parent
c5505cd37e
commit
4902f01391
@ -31,6 +31,11 @@ class Validator
|
||||
*/
|
||||
public const EMPTY_VALUES = [null, '', []];
|
||||
|
||||
/**
|
||||
* Date format used for date fields
|
||||
*/
|
||||
public const DATE_FORMAT = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* Validate all Fields against given data
|
||||
*/
|
||||
@ -107,7 +112,7 @@ class Validator
|
||||
}
|
||||
|
||||
try {
|
||||
return date('Y-m-d H:i:s', Date::toTimestamp($value));
|
||||
return date(self::DATE_FORMAT, Date::toTimestamp($value));
|
||||
} catch (InvalidArgumentException $e) {
|
||||
throw new ValidationException(sprintf('Invalid value for field "%s" of type "%s":%s', $field->name(), $field->type(), Str::after($e->getMessage(), ':')));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user