Skip to content

Commit

Permalink
Remove vehicle-registration validation
Browse files Browse the repository at this point in the history
  • Loading branch information
oddsson committed Jan 3, 2025
1 parent dd1b223 commit 7570e01
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,17 @@ export const IndictmentCount: FC<Props> = ({
</Box>
)}
<Box marginBottom={2}>
<InputMask
mask={[/[A-Z]/i, /[A-Z]/i, /[A-Z]|[0-9]/i, /[0-9]/, /[0-9]/]}
maskPlaceholder={null}
<Input
name="vehicleRegistrationNumber"
autoComplete="off"
label={formatMessage(strings.vehicleRegistrationNumberLabel)}
placeholder={formatMessage(
strings.vehicleRegistrationNumberPlaceholder,
)}
value={indictmentCount.vehicleRegistrationNumber ?? ''}
beforeMaskedStateChange={({ nextState }) => {
let { value } = nextState
value = value.toUpperCase()

return { ...nextState, value }
}}
onChange={(event) => {
removeErrorMessageIfValid(
['empty', 'vehicle-registration-number'],
['empty'],
event.target.value,
vehicleRegistrationNumberErrorMessage,
setVehicleRegistrationNumberErrorMessage,
Expand All @@ -538,7 +536,7 @@ export const IndictmentCount: FC<Props> = ({
}}
onBlur={async (event) => {
validateAndSetErrorMessage(
['empty', 'vehicle-registration-number'],
['empty'],
event.target.value,
setVehicleRegistrationNumberErrorMessage,
)
Expand All @@ -547,19 +545,10 @@ export const IndictmentCount: FC<Props> = ({
vehicleRegistrationNumber: event.target.value,
})
}}
>
<Input
name="vehicleRegistrationNumber"
autoComplete="off"
label={formatMessage(strings.vehicleRegistrationNumberLabel)}
placeholder={formatMessage(
strings.vehicleRegistrationNumberPlaceholder,
)}
errorMessage={vehicleRegistrationNumberErrorMessage}
hasError={vehicleRegistrationNumberErrorMessage !== ''}
required
/>
</InputMask>
errorMessage={vehicleRegistrationNumberErrorMessage}
hasError={vehicleRegistrationNumberErrorMessage !== ''}
required
/>
</Box>
<Box marginBottom={2}>
<Select
Expand Down
35 changes: 0 additions & 35 deletions apps/judicial-system/web/src/utils/validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,38 +261,3 @@ describe('Validate court case number', () => {
},
)
})

describe('Validate vehicle registration number', () => {
test.each`
vehicleRegistrationNumber
${'AB123'}
${'QWE23'}
`(
'should pass when vehicle registration number is in correct format $vehicle-registration-number',
({ vehicleRegistrationNumber }) => {
const result = validate([
[vehicleRegistrationNumber, ['vehicle-registration-number']],
])
expect(result.isValid).toEqual(true)
},
)

test.each`
vehicleRegistrationNumber
${'ABCDE'}
${'12345'}
${'ABCD5'}
${'A1234'}
${'AB-123'}
${'ABC-23'}
`(
'should fail when vehicle registration number is in incorrect format $vehicle-registration-number',
({ vehicleRegistrationNumber }) => {
const result = validate([
[vehicleRegistrationNumber, ['vehicle-registration-number']],
])
expect(result.isValid).toEqual(false)
expect(result.errorMessage).toEqual('Dæmi: AB123')
},
)
})
7 changes: 0 additions & 7 deletions apps/judicial-system/web/src/utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export type Validation =
| 'date-format'
| 'R-case-number'
| 'S-case-number'
| 'vehicle-registration-number'
| 'appeal-case-number-format'

type ValidateItem = 'valid' | [string | undefined | null, Validation[]]
Expand Down Expand Up @@ -94,12 +93,6 @@ const getRegexByValidation = (validation: Validation) => {
errorMessage: `Dæmi: S-1234/${new Date().getFullYear()}`,
}
}
case 'vehicle-registration-number': {
return {
regex: new RegExp(/^[A-Z]{2}([A-Z]{1}|[0-9]{1})[0-9]{2}$/),
errorMessage: 'Dæmi: AB123',
}
}
case 'appeal-case-number-format': {
return {
regex: new RegExp(/^[0-9]{1,4}\/[0-9]{4}$/),
Expand Down

0 comments on commit 7570e01

Please sign in to comment.