strapi/packages/core/content-releases/shared/validation-schemas.ts
Madhuri Sandbhor 8d3598965d
Feat(releases): Ability to schedule a release (#19498)
* added first draft for releases scheduling

* update: scheduled date is made Date or nullable, tests updated for scheduling fields

* fix: pass scheduled date null on edit unchecking the option

* fix: dirty check added for disabling save button

* timezone hook added to generate list of timezone options

* update: timezone added in payload to save in DB

* update: removed grouping and sorting of timezones, keeping simple UTC+/-HH:00 <timezone> format

* fix: removing unnecessary code

* update: creating new release should show schedule by default

* minor change

* tests: queryByRole replaced with getByRole query

* update: use date-fns format functions instead of manually formattingdates, future flag added on front for Scheduling till beta release, test cases updated

* fix: comment added

* minor change

* fix: reverting merging change

* fix: scheduledAt and timezone types updated to be null instead of undefined to keep it consistent

* fix: converted utc to zoned time to update correct time on editing the release

* fix: handled validation on submit, always enable submit, timezone list updated based on selected date

* update: default timezone set, tests updated

* update: selecting date during DST updates the timezone selected and list, TS errors fixed

* fix: timezone display value updated

* fix: e2e tests

* update: e2e added for scheduling info

* fix: minor change

* fix: schema validation reverted, tests updated for findBy
2024-02-20 05:32:14 +01:00

27 lines
725 B
TypeScript

import * as yup from 'yup';
export const RELEASE_SCHEMA = yup
.object()
.shape({
name: yup.string().trim().required(),
scheduledAt: yup.string().nullable(),
isScheduled: yup.boolean().optional(),
time: yup.string().when('isScheduled', {
is: true,
then: yup.string().trim().required(),
otherwise: yup.string().nullable(),
}),
timezone: yup.string().when('isScheduled', {
is: true,
then: yup.string().required().nullable(),
otherwise: yup.string().nullable(),
}),
date: yup.string().when('isScheduled', {
is: true,
then: yup.string().required().nullable(),
otherwise: yup.string().nullable(),
}),
})
.required()
.noUnknown();