Skip to content

Commit

Permalink
fix file and date schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Oct 5, 2024
1 parent f058e6c commit 69cfe98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/pages/Funds/CreateFund/CreateFund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default withAuth(function CreateFund() {
description: "",
logo: { preview: "", publicUrl: "" },
banner: { preview: "", publicUrl: "" },
expiration: "",
featured: true,
members: [],
settings: {
Expand Down
26 changes: 14 additions & 12 deletions src/pages/Funds/CreateFund/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ const fileObject = v.object({
});

export const imgLink = v.object({
file: v.optional(
v.pipe(
v.file(),
v.mimeType(VALID_MIME_TYPES, "invalid type"),
v.maxSize(MAX_SIZE_IN_BYTES, "exceeds size limit")
)
file: v.pipe(
v.file("required"),
v.mimeType(VALID_MIME_TYPES, "invalid type"),
v.maxSize(MAX_SIZE_IN_BYTES, "exceeds size limit")
),
preview: v.pipe(str, v.url()),
...fileObject.entries,
Expand Down Expand Up @@ -42,12 +40,16 @@ export const schema = v.object({
),
featured: v.boolean(),
settings,
expiration: v.pipe(
str,
v.nonEmpty("required"),
v.transform((v) => new Date(v).toISOString()),
v.isoTimestamp("invalid date"),
v.minValue(new Date().toISOString(), "must be in the future")
expiration: v.optional(
v.lazy((val) => {
if (!val) return v.string();
return v.pipe(
v.string(),
v.transform((val) => val && new Date(val).toISOString()),
v.isoTimestamp("invalid date"),
v.minValue(new Date().toISOString(), "must be in the future")
);
})
),
target,
});
Expand Down

0 comments on commit 69cfe98

Please sign in to comment.