Created
March 7, 2021 09:23
datepicker-yup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define schema | |
export const companySchema = object({ | |
yearEndDate: date().nullable().typeError('Invalid Date'), | |
}); | |
export type Company = Asserts<typeof companySchema>; | |
//deconstruct `control` and `errors` | |
const { reset, control, handleSubmit, errors } = useForm<Company>({ | |
resolver: yupResolver(companySchema) | |
}); | |
//assign `error` and `helperText` | |
<EpicDatePicker | |
control={control} | |
name={'yearEndDate'} | |
label={'Year End Date'} | |
error={!!errors.yearEndDate} | |
helperText={errors.yearEndDate?.message} | |
/> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment