/**
* An Effect Schema representation of an {@link EventDate}.
*/
export const EventDate = Schema.transform(
Schema.String.pipe(
Schema.nonEmptyString({ message: () => "Cannot be empty." }),
Schema.pattern(
/^(?!0000)\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/,
{ message: () => "Date must be in the pattern of yyyy-MM-dd" },
),
),
Schema.typeSchema(Schema.Date),
{
strict: true,
decode: (str: string) => parseISO(str),
encode: (date: Date) => format(date, "yyyy-MM-dd"),
},
).pipe(Schema.brand("EventDate"));
/**
* The date of the training event.
*/
export type EventDate = Schema.Schema.Type<typeof EventDate>;
/**
* An Effect Schema representation of an {@link EventDate}.
*/
export const EventDate = Schema.transform(
Schema.String.pipe(
Schema.nonEmptyString({ message: () => "Cannot be empty." }),
Schema.pattern(
/^(?!0000)\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/,
{ message: () => "Date must be in the pattern of yyyy-MM-dd" },
),
),
Schema.typeSchema(Schema.Date),
{
strict: true,
decode: (str: string) => parseISO(str),
encode: (date: Date) => format(date, "yyyy-MM-dd"),
},
).pipe(Schema.brand("EventDate"));
/**
* The date of the training event.
*/
export type EventDate = Schema.Schema.Type<typeof EventDate>;