Skip to content

Commit c4a7ac3

Browse files
committed
Merge branch 'master' into 6_mailto_percent_signs
2 parents f975cd8 + c0ad5ba commit c4a7ac3

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

README.org

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ If you want to use validations from JavaScript, first build the js:
133133
=target/js/xapi_schema.js= and invoke:
134134

135135
#+BEGIN_SRC javascript
136-
var statement-str = '{"id":"fd41c918-b88b-4b20-a0a5-a4c32391aaa0", "actor":{"objectType": "Agent","name":"Project Tin Can API","mbox":"mailto:user@example.com"},"verb":{"id":"http://example.com/xapi/verbs#sent-a-statement","display":{ "en-US":"sent" }},"object":{"id":"http://example.com/xapi/activity/simplestatement","definition":{"name":{ "en-US":"simple statement" },"description":{ "en-US":"A simple Experience API statement. Note that the LRS does not need to have any prior information about the Actor (learner), the verb, or the Activity/object." }}}}';
137-
var statement-json = JSON.parse(s);
138-
xapi_schema.core.validate_statement_data_js(statement-str); // => statement JSON
139-
xapi_schema.core.validate_statement_data_js(statement-json); // => statement JSON
136+
var statement_str = '{"id":"fd41c918-b88b-4b20-a0a5-a4c32391aaa0", "actor":{"objectType": "Agent","name":"Project Tin Can API","mbox":"mailto:user@example.com"},"verb":{"id":"http://example.com/xapi/verbs#sent-a-statement","display":{ "en-US":"sent" }},"object":{"id":"http://example.com/xapi/activity/simplestatement","definition":{"name":{ "en-US":"simple statement" },"description":{ "en-US":"A simple Experience API statement. Note that the LRS does not need to have any prior information about the Actor (learner), the verb, or the Activity/object." }}}}';
137+
var statement_json = JSON.parse(s);
138+
xapi_schema.core.validate_statement_data_js(statement_str); // => statement JSON
139+
xapi_schema.core.validate_statement_data_js(statement_json); // => statement JSON
140140
#+END_SRC
141141

142142
** Testing

spec/cljx/xapi_schema/schemata/json_spec.cljx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@
124124
(it "is a valid ISO 8601 DateTime"
125125
(should-satisfy+ Timestamp
126126
"2014-09-10T14:12:05Z"
127+
"2015-06-30T23:59:60Z" ;; leap second
127128
:bad
128-
"09-10-2014T14:12:00+500")))
129+
"09-10-2014T14:12:00+500"
130+
"2014-09-12T03:47:40" ;; no time zone
131+
)))
129132
(describe
130133
"Duration"
131134
(it "is a valid ISO 8601 Duration"
@@ -142,8 +145,20 @@
142145
"1.0.1"
143146
"1.0.2"
144147
"1.0.3"
148+
"1.0.3-rc1"
149+
"1.0.0-alpha"
150+
"1.0.0-alpha.1"
151+
"1.0.0-0.3.7"
152+
"1.0.0-x.7.z.92"
145153
:bad
146154
"0.9.5"
155+
"1.0." ;; bad semver
156+
"1.0.0-.123"
157+
"1.0.0-..."
158+
"1.0.0-123."
159+
"1.0.0-+"
160+
"1.0.0-+123"
161+
"1.0.0-"
147162
"what's going on?")))
148163

149164
(describe

src/cljx/xapi_schema/schemata/regex.cljx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
#"[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-4[0-9A-Za-z]{3}-[89ABab][0-9A-Za-z]{3}-[0-9A-Za-z]{12}")
2323

2424
(def TimestampRegEx
25-
#"^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$")
25+
#"^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)|T23:59:60Z)?)?$")
2626

27+
;; Based on http://www.regexr.com/39s32
2728
(def xAPIVersionRegEx
28-
#"^1\.0\.(\d+)?$")
29+
#"^((1\.0\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$")
2930

3031
(def DurationRegEx
3132
#"^P((\d+([\.,]\d+)?Y)?(\d+([\.,]\d+)?M)?(\d+([\.,]\d+)?W)?(\d+([\.,]\d+)?D)?)?(T(\d+([\.,]\d+)?H)?(\d+([\.,]\d+)?M)?(\d+([\.,]\d+)?S)?)?$")

0 commit comments

Comments
 (0)