Skip to content

Commit

Permalink
[#65] Fix validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Dec 1, 2023
1 parent 6748489 commit 20e2069
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/registry/address/edit-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@ import {IntlShape} from 'react-intl';
import {z} from 'zod';

import {buildCommonSchema} from '@/registry/validation';

import {POSTCODE_REGEX} from '../postcode/constants';

// Constraints taken from the BRK API (apart from postcode which comes from our postcode component)
const addressSchema = z.object({
postcode: z.string().regex(new RegExp(POSTCODE_REGEX)),
houseNumber: z.string().regex(/^\d{1,5}$/),
houseLetter: z.string().regex(/^[a-zA-Z]$/),
postcode: z.string().regex(new RegExp(POSTCODE_REGEX)).optional(),
houseNumber: z
.string()
.regex(/^\d{1,5}$/)
.optional(),
houseLetter: z
.string()
.regex(/^[a-zA-Z]$/)
.optional(),
houseNumberAddition: z
.string()
.regex(/^([a-z,A-Z,0-9]){1,4}$/)
Expand Down

0 comments on commit 20e2069

Please sign in to comment.