Add schema utils
This commit is contained in:
parent
c8a729f8be
commit
b26466e59d
45 changed files with 674 additions and 151 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue