mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE): Validate end_date is not before start_date
This commit is contained in:
@@ -12,7 +12,18 @@ export type UniformityTableFilterType = {
|
|||||||
|
|
||||||
export const UniformityTableFilterSchema = yup.object({
|
export const UniformityTableFilterSchema = yup.object({
|
||||||
start_date: yup.string().required('Tanggal mulai wajib diisi'),
|
start_date: yup.string().required('Tanggal mulai wajib diisi'),
|
||||||
end_date: yup.string().required('Tanggal akhir wajib diisi'),
|
end_date: yup
|
||||||
|
.string()
|
||||||
|
.required('Tanggal akhir wajib diisi')
|
||||||
|
.test(
|
||||||
|
'is-greater-than-start',
|
||||||
|
'Tanggal akhir tidak boleh masa lampau',
|
||||||
|
function (value) {
|
||||||
|
const { start_date } = this.parent;
|
||||||
|
if (!start_date || !value) return true;
|
||||||
|
return new Date(value) >= new Date(start_date);
|
||||||
|
}
|
||||||
|
),
|
||||||
location: yup
|
location: yup
|
||||||
.mixed<OptionType>()
|
.mixed<OptionType>()
|
||||||
.required('Lokasi wajib dipilih')
|
.required('Lokasi wajib dipilih')
|
||||||
|
|||||||
Reference in New Issue
Block a user