Skip to content

Commit bf6ae11

Browse files
committed
Merge pull request #14 from yetanalytics/5_duration_regex
5 duration regex
2 parents 704e8d1 + 4dc8ec3 commit bf6ae11

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

spec/cljx/xapi_schema/schemata/json_spec.cljx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,13 @@
134134
(it "is a valid ISO 8601 Duration"
135135
(should-satisfy+ Duration
136136
"P3Y6M4DT12H30M5S"
137+
"P3Y6M4DT12H30M5.2S" ;; good fractional
137138
:bad
138-
"2 hours")))
139+
"2 hours"
140+
"P"
141+
"PT"
142+
"P3Y6M4DT12H30.1M5S" ;; bad fractional
143+
)))
139144

140145
(describe
141146
"Version"

src/cljx/xapi_schema/schemata/regex.cljx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#"^((1\.0\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$")
3030

3131
(def DurationRegEx
32-
#"^P((\d+([\.,]\d+)?Y)?(\d+([\.,]\d+)?M)?(\d+([\.,]\d+)?W)?(\d+([\.,]\d+)?D)?)?(T(\d+([\.,]\d+)?H)?(\d+([\.,]\d+)?M)?(\d+([\.,]\d+)?S)?)?$")
32+
#"P(?:(?:(?:\d+D|\d+\.\d+D$)|(?:\d+M|\d+\.\d+M$)(?:\d+D|\d+\.\d+D$)?|(?:\d+Y|\d+\.\d+Y$)(:?(?:\d+M|\d+\.\d+M$)(?:\d+D|\d+\.\d+D$)?)?)(:?T(?:(?:\d+H|\d+\.\d+H$)(?:(?:\d+M|\d+\.\d+M$)(?:\d+S|\d+\.\d+S$)?)?|(?:\d+M|\d+\.\d+M$)(?:\d+S|\d+\.\d+S$)?|(?:\d+S|\d+\.\d+S$)))?|T(?:(?:\d+H|\d+\.\d+H$)(?:(?:\d+M|\d+\.\d+M$)(?:\d+S|\d+\.\d+S$)?)?|(?:\d+M|\d+\.\d+M$)(?:\d+S|\d+\.\d+S$)?|(?:\d+S|\d+\.\d+S$))|(?:\d+W|\d+\.\d+W$))")
3333

3434
(def Base64RegEx
3535
#"^(?:[A-Za-z0-9\+\/]{4})*(?:[A-Za-z0-9\+\/]{2}==|[A-Za-z0-9\+\/]{3}=|[A-Za-z0-9\+\/]{4})$")

0 commit comments

Comments
 (0)