export const FooId = Schema.UUID.pipe(Schema.brand("FoodId"));
export type FooId = typeof FooId.Type;
export const Bar = Schema.NonEmptyTrimmedString.pipe(
Schema.brand("Bar"),
Model.fieldEvolve({
jsonCreate: () =>
Schema.Trim.pipe(
Schema.nonEmptyString({ description: "bar is required" }),
// Further validations
),
jsonUpdate: () =>
Schema.Trim.pipe(
Schema.nonEmptyString({ description: "bar is required" }),
Schema.optional,
),
}),
);
export type Bar = typeof Bar.schemas.select.Type;
export class Foo extends Model.Class<Foo>("Foo")({
id: Model.Generated(FooId),
bar: Bar,
}) {}
export const FooId = Schema.UUID.pipe(Schema.brand("FoodId"));
export type FooId = typeof FooId.Type;
export const Bar = Schema.NonEmptyTrimmedString.pipe(
Schema.brand("Bar"),
Model.fieldEvolve({
jsonCreate: () =>
Schema.Trim.pipe(
Schema.nonEmptyString({ description: "bar is required" }),
// Further validations
),
jsonUpdate: () =>
Schema.Trim.pipe(
Schema.nonEmptyString({ description: "bar is required" }),
Schema.optional,
),
}),
);
export type Bar = typeof Bar.schemas.select.Type;
export class Foo extends Model.Class<Foo>("Foo")({
id: Model.Generated(FooId),
bar: Bar,
}) {}