Skip to content

Commit

Permalink
Merge pull request #488 from projectNEWM/STUD-65-update-min-release-date
Browse files Browse the repository at this point in the history
fix: Update logic to min scheduled release date validation
  • Loading branch information
escobarjonatan authored Feb 1, 2024
2 parents 1dd8dc3 + 3071e88 commit 1d8d507
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions apps/studio/src/common/formUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,16 @@ export const commonYupValidation = {
password: Yup.string().required("Password is required"),
publicationDate: Yup.date().max(new Date(), "Cannot be a future date"),
releaseDate: (releaseDate: string | undefined) => {
// If releaseDate is provided, use it.
// Otherwise, use the minimum time for EVEARA to distribute from now.
const minReleaseDate = releaseDate
? new Date(releaseDate)
: new Date(Date.now() + MIN_DISTRIBUTION_TIME * 24 * 60 * 60 * 1000);

// Yup min validation is not inclusive, subtract 1 day from release date.
// The comparison is done using the ISO string format to ensure consistent behavior
// across different time zones.
return Yup.date()
.required("This field is required")
.min(
new Date(minReleaseDate.getTime() - 24 * 60 * 60 * 1000),
minReleaseDate.toISOString().split("T")[0], // Compare using ISO format
`Release date must be on or after ${
minReleaseDate.toISOString().split("T")[0]
}`
Expand Down

0 comments on commit 1d8d507

Please sign in to comment.