Skip to content

Commit

Permalink
fix(dateInput): fix bad date handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Clm-Roig committed Sep 28, 2022
1 parent 2378dfe commit 5707803
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/forms/TrackerForm/TrackerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ const TrackerForm: FC<Props> = ({ initialValues, onSubmit }) => {
<DateInput
id="begin-date"
name="beginDate"
rules={{ required: { value: true, message: 'Une date de début est requise.' } }}
rules={{
required: { value: true, message: 'Une date de début est requise.' },
validate: (value) =>
!Number.isNaN(new Date(value).getTime()) || 'Format de la date incorrect.'
}}
fullWidth
label="Date de début"
sx={{ mb: 2 }}
Expand Down
1 change: 0 additions & 1 deletion src/components/forms/formElements/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const DateInput: FC<TextInputProps> = (props) => {
fullWidth
error={!!error}
helperText={error ? error.message : ''}
onChange={onChange}
required={!!rules?.required}
value={value}
{...textFieldProps}
Expand Down

0 comments on commit 5707803

Please sign in to comment.