Skip to content

Commit

Permalink
Resolve #24: Disallow entry of improperly formatted times
Browse files Browse the repository at this point in the history
  • Loading branch information
big213 committed Aug 15, 2021
1 parent 48bafaa commit e07724c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ export default {
if (!val) return
// if pasted value matches the correct format, don't do anything
if (val.match(/^(\d+:)?\d{1,2}\.\d{2}$/)) return
if (val.match(/^(\d+:)?[1-5]?\d\.\d{2}$/)) return
// if val is 1 or more digits only, parse
if (val.match(/^\d+$/)) {
return this.setInputValue('timeElapsed', this.parseTimeString(val))
}
// if val is 1 digit off from a correct string, must be due to a keyboard action. parse
if (val.match(/^(\d+:)?\d{1,2}\.\d{1,3}$/)) {
if (val.match(/^(\d+:)?[1-5]?\d\.\d{1,3}$/)) {
return this.setInputValue('timeElapsed', this.parseTimeString(val))
}
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/models/personalBest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const PersonalBest = <RecordInfo<'personalBest'>>{
hint: 'Type in the numbers only, the numbers will be auto-formatted',
inputRules: [
(value) => {
const regEx = /^(\d+:)?\d{1,2}\.\d{2}$/
const regEx = /^(\d+:)?[1-5]?\d\.\d{2}$/
return (
!value ||
regEx.test(value) ||
Expand Down

0 comments on commit e07724c

Please sign in to comment.