Add schema utils

This commit is contained in:
Jamie Kyle 2024-10-02 12:03:10 -07:00 committed by GitHub
parent c8a729f8be
commit b26466e59d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 674 additions and 151 deletions

View file

@ -15,6 +15,7 @@ import { Input } from './Input';
import { AutoSizeTextArea } from './AutoSizeTextArea';
import { Button, ButtonVariant } from './Button';
import { strictAssert } from '../util/assert';
import { safeParsePartial } from '../util/schemas';
const formSchema = z.object({
nickname: z
@ -67,7 +68,7 @@ export function EditNicknameAndNoteModal({
const familyNameValue = toOptionalStringValue(familyName);
const noteValue = toOptionalStringValue(note);
const hasEitherName = givenNameValue != null || familyNameValue != null;
return formSchema.safeParse({
return safeParsePartial(formSchema, {
nickname: hasEitherName
? { givenName: givenNameValue, familyName: familyNameValue }
: null,