Skip to content

Commit 92322a8

Browse files
committed
fix street level address validation
1 parent cbbc206 commit 92322a8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/form/street-address-configuration.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
defineFormConditional,
1010
errorMessages
1111
} from '@opencrvs/toolkit/events'
12-
import { type } from 'os'
1312

1413
function isInternationalAddress() {
1514
return and(
@@ -43,12 +42,33 @@ export function getNestedFieldValidators(
4342
[fieldId]: {
4443
type: 'object',
4544
properties: {
46-
[field.id]: {
47-
minLength: 1
45+
addressType: {
46+
type: 'string',
47+
enum: ['INTERNATIONAL', 'DOMESTIC']
48+
},
49+
streetLevelDetails: {
50+
type: 'object',
51+
properties: {
52+
[field.id]: { minLength: 1 }
53+
}
54+
}
55+
},
56+
if: {
57+
properties: {
58+
addressType: { const: 'INTERNATIONAL' }
59+
}
60+
},
61+
then: {
62+
required: ['streetLevelDetails'],
63+
properties: {
64+
streetLevelDetails: {
65+
required: [field.id]
66+
}
4867
}
4968
}
5069
}
51-
}
70+
},
71+
required: [fieldId]
5272
})
5373
}))
5474
}

0 commit comments

Comments
 (0)