mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-23 18:15:08 +00:00
feat: allow first name and display name to be optional (#1288)
Co-authored-by: Kyle Mendell <kmendell@ofkm.us>
This commit is contained in:
@@ -122,6 +122,11 @@ export function createForm<T extends z.ZodType<any, any>>(schema: T, initialValu
|
||||
}
|
||||
|
||||
function isRequired(fieldSchema: z.ZodTypeAny): boolean {
|
||||
// Handle string allow empty
|
||||
if (fieldSchema instanceof z.ZodString) {
|
||||
return fieldSchema.minLength !== null && fieldSchema.minLength > 0;
|
||||
}
|
||||
|
||||
// Handle unions like callbackUrlSchema
|
||||
if (fieldSchema instanceof z.ZodUnion) {
|
||||
return !fieldSchema.def.options.some((o: any) => {
|
||||
@@ -138,6 +143,7 @@ export function createForm<T extends z.ZodType<any, any>>(schema: T, initialValu
|
||||
if (fieldSchema instanceof z.ZodOptional || fieldSchema instanceof z.ZodDefault) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user