Skip to content

Commit

Permalink
fix: optional phone number has required behavior ❗️ (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiAbdou authored Sep 26, 2024
1 parent 335c3f8 commit 2849453
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/types/src/domain/student.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from './types';
import { normalizeUri } from '../../../utils/src/index';
import { type ExtractValue } from '../shared/types';
import { NullishString } from '../shared/zod';
import { EmptyStringToNull, NullishString } from '../shared/zod';

// Enums

Expand Down Expand Up @@ -172,7 +172,7 @@ export const Student = Entity.merge(StudentSocialLinks)
.string()
.trim()
.regex(/^\d{10}$/, 'Must be a 10-digit number.')
.optional(),
.or(EmptyStringToNull),

/**
* The preferred name that a member would like to go by. This will typically
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/shared/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const BooleanInput = z.preprocess((value) => {
return typeof value === 'boolean' ? value : value === '1';
}, z.boolean());

export const EmptyStringToNull = z.literal('').transform(() => null);

export const ISO8601Date = z.coerce.date().transform((value) => {
return value.toISOString().split('T')[0];
});
Expand Down

0 comments on commit 2849453

Please sign in to comment.