We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What you were expecting:
Show error message after trigger validation when clear DateTimeInput, if required is include in its validate props.
DateTimeInput
required
What happened instead:
Did NOT Show error message after trigger validation when clear DateTimeInput, if required is include in its validate props.
If DateTimeInput had been set a value, the required validation will always be passed.
Steps to reproduce:
DataTimeInput
Related code:
DateTimeInput.tsx#L18
const parseDateTime = (value: string) => new Date(value);
After clear field, parseDateTime will receive '' (empty string) as value, and return Invalid Date with type is Date object.
parseDateTime
''
Invalid Date
Date
validate.ts#L145 and validate.ts#L7
validate.ts#L145
validate.ts#L7
export const required = memoize((message = 'ra.validation.required') => Object.assign( (value, values) => isEmpty(value) ? getMessage(message, undefined, value, values) : undefined, { isRequired: true } ) );
const isEmpty = (value: any) => typeof value === 'undefined' || value === null || value === '' || (Array.isArray(value) && value.length === 0);
isEmpty return false if Invalid Date (Date object) as value pass into.
isEmpty
false
value
Environment
The text was updated successfully, but these errors were encountered:
reproduced, thanks!
Sorry, something went wrong.
<DateTimeInput validate={required()} />
Successfully merging a pull request may close this issue.
What you were expecting:
Show error message after trigger validation when clear
DateTimeInput
, ifrequired
is include in its validate props.What happened instead:
Did NOT Show error message after trigger validation when clear
DateTimeInput
, ifrequired
is include in its validate props.If
DateTimeInput
had been set a value, therequired
validation will always be passed.Steps to reproduce:
DateTimeInput
. (Use browser UI or just typing, whatever)DataTimeInput
which just give a datetime.Related code:
DateTimeInput.tsx#L18
After clear field,
parseDateTime
will receive''
(empty string) as value, and returnInvalid Date
with type isDate
object.validate.ts#L145
andvalidate.ts#L7
isEmpty
returnfalse
ifInvalid Date
(Date
object) asvalue
pass into.Environment
The text was updated successfully, but these errors were encountered: