import * as S from '@effect/schema/Schema'
export const CreateMissionInputSharedSchema = S.Struct({
isPastEvent: S.NullOr(S.Boolean),
endDate: S.NullOr(S.Date),
})
export const CreateRegisterMissionInputSchema = S.Struct({
...CreateMissionInputSharedSchema.fields,
// Simpler example, but the actual schema is more complex
otherFields: S.String,
})
export const CreateBridgeMissionInputSchema = S.Struct({
...CreateMissionInputSharedSchema.fields,
// Simpler example, but the actual schema is more complex
otherFields2: S.String,
})
// Simpler example, but the actual schema is more complex
export const CreateMissionInputSchema = S.Union(
CreateRegisterMissionInputSchema,
CreateBridgeMissionInputSchema,
)
const PastMissionOverrides = S.Struct({
isPastEvent: S.Boolean.pipe(
S.filter(isPastEvent =>
isPastEvent || {
path: ['isPastEvent'],
message: 'isPastEvent must be true',
}
),
),
endDate: S.Date.pipe(S.filter(endDate =>
endDate < new Date() || {
path: ['endDate'],
message: 'endDate must be a past date',
}
)),
})
export const CreatePastMissionInputSchema = S.extend(
CreateMissionInputSchema,
PastMissionOverrides,
)
import * as S from '@effect/schema/Schema'
export const CreateMissionInputSharedSchema = S.Struct({
isPastEvent: S.NullOr(S.Boolean),
endDate: S.NullOr(S.Date),
})
export const CreateRegisterMissionInputSchema = S.Struct({
...CreateMissionInputSharedSchema.fields,
// Simpler example, but the actual schema is more complex
otherFields: S.String,
})
export const CreateBridgeMissionInputSchema = S.Struct({
...CreateMissionInputSharedSchema.fields,
// Simpler example, but the actual schema is more complex
otherFields2: S.String,
})
// Simpler example, but the actual schema is more complex
export const CreateMissionInputSchema = S.Union(
CreateRegisterMissionInputSchema,
CreateBridgeMissionInputSchema,
)
const PastMissionOverrides = S.Struct({
isPastEvent: S.Boolean.pipe(
S.filter(isPastEvent =>
isPastEvent || {
path: ['isPastEvent'],
message: 'isPastEvent must be true',
}
),
),
endDate: S.Date.pipe(S.filter(endDate =>
endDate < new Date() || {
path: ['endDate'],
message: 'endDate must be a past date',
}
)),
})
export const CreatePastMissionInputSchema = S.extend(
CreateMissionInputSchema,
PastMissionOverrides,
)