Skip to content

Commit

Permalink
set regexp for polish grades validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Agilulfo committed Sep 19, 2024
1 parent 4ac4a7f commit 0889500
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/__tests__/scales/polish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { Polish } from '../../scales'

describe('Polish', () => {
describe('isPolish', () => {
test('VI', () => {
expect(Polish.isType('VI'))
test('VI is a valid grade', () => {
expect(Polish.isType('VI')).toBe(true)
})
test('asd is not a valid grade', () => {
expect(Polish.isType('asd')).toBe(false)
})
})
// describe('Get Score', () => {
Expand Down
6 changes: 1 addition & 5 deletions src/scales/polish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'

// TODO: set this regexp
const polishGradeRegex = /^([1-9][a-c][+]?){1}(?:(\/)([1-9][a-c][+]?))?$/i
// Supports 1a -> 9c+, slash grades i.e. 5a/5a+ or 6a+/6b
// NOTE: this currently assumes "incorrect" slash grades follows the normal pattern
// i.e. 6b+/5a => 6b+/6c
const polishGradeRegex = /^((I{1,3})|(IV\+?)|(V[+,-]?)|(VI(.[1-9])?\+?))?$/i
const isPolish = (grade: string): RegExpMatchArray | null => grade.match(polishGradeRegex)

const PolishScale: GradeScale = {
Expand Down

0 comments on commit 0889500

Please sign in to comment.