Skip to content

Commit

Permalink
Morecast Validation Tweak (#3962)
Browse files Browse the repository at this point in the history
Tweak RH and wind speed validation
- RH between 1-100
- Wind Speed between 0-99
  • Loading branch information
brettedw authored Sep 25, 2024
1 parent 817518c commit c2df18c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions web/src/features/moreCast2/components/MoreCast2Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const windDirForecastField = new IndeterminateField(
)

export const rhForecastField = new IndeterminateField('rh', RH_HEADER, 'number', 0, true, (value: string) => {
return Number(value) < 0 || Number(value) > 100 ? 'RH must be between 0 and 100' : ''
return value !== '' && (Number(value) < 1 || Number(value) > 100) ? 'RH must be between 1 and 100' : ''
})
export const windSpeedForecastField = new IndeterminateField(
'windSpeed',
Expand All @@ -203,7 +203,7 @@ export const windSpeedForecastField = new IndeterminateField(
0,
true,
(value: string) => {
return Number(value) < 0 || Number(value) > 120 ? 'Wind speed must be between 0 and 120 kph' : ''
return Number(value) < 0 || Number(value) > 99 ? 'Wind speed must be between 0 and 99 kph' : ''
}
)
export const precipForecastField = new IndeterminateField(
Expand Down
12 changes: 6 additions & 6 deletions web/src/features/moreCast2/components/moreCast2Column.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ describe('MoreCast2Column', () => {
)
})
it('should have correct validation logic', () => {
expect(rhForecastField.validator && rhForecastField.validator('101')).toEqual('RH must be between 0 and 100')
expect(rhForecastField.validator && rhForecastField.validator('101')).toEqual('RH must be between 1 and 100')

expect(rhForecastField.validator && rhForecastField.validator('-1')).toEqual('RH must be between 0 and 100')
expect(rhForecastField.validator && rhForecastField.validator('-1')).toEqual('RH must be between 1 and 100')

expect(rhForecastField.validator && rhForecastField.validator('0')).toEqual('')
expect(rhForecastField.validator && rhForecastField.validator('1')).toEqual('')
})
})
describe('WindDirForecastField', () => {
Expand Down Expand Up @@ -153,12 +153,12 @@ describe('MoreCast2Column', () => {
)
})
it('should have correct validation logic', () => {
expect(windSpeedForecastField.validator && windSpeedForecastField.validator('121')).toEqual(
'Wind speed must be between 0 and 120 kph'
expect(windSpeedForecastField.validator && windSpeedForecastField.validator('100')).toEqual(
'Wind speed must be between 0 and 99 kph'
)

expect(windSpeedForecastField.validator && windSpeedForecastField.validator('-1')).toEqual(
'Wind speed must be between 0 and 120 kph'
'Wind speed must be between 0 and 99 kph'
)

expect(windSpeedForecastField.validator && windSpeedForecastField.validator('0')).toEqual('')
Expand Down

0 comments on commit c2df18c

Please sign in to comment.