Skip to content

Commit

Permalink
validate PA message interval field
Browse files Browse the repository at this point in the history
  • Loading branch information
panentheos committed Nov 1, 2024
1 parent 898f42c commit 255980d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/js/components/Dashboard/IntervalPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ const IntervalPicker = ({ interval, onChangeInterval, validated }: Props) => {
className="m-0 interval"
type="number"
value={interval}
min={1}
onChange={(input) => onChangeInterval(input.target.value)}
required
isInvalid={validated && interval.length === 0}
isInvalid={validated && (!Number.isInteger(+interval) || +interval < 1)}
/>
<Form.Control.Feedback type="invalid">
Interval value is required
Interval value must be a positive integer
</Form.Control.Feedback>
</Form.Group>
);
Expand Down
2 changes: 2 additions & 0 deletions lib/screenplay/pa_messages/pa_message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ defmodule Screenplay.PaMessages.PaMessage do
])
|> validate_length(:sign_ids, min: 1)
|> validate_subset(:days_of_week, 1..7)
|> validate_number(:interval_in_minutes, greater_than: 0)
|> validate_inclusion(:priority, 1..4)
|> validate_start_date()
|> validate_end_date()
|> maybe_unpause()
Expand Down

0 comments on commit 255980d

Please sign in to comment.