Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(j-s): Remove vehicle registration number validation #17401

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading