File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,7 @@ const skip = new Set<string>([
9494 "|draft2020-12|uri-template.json" ,
9595 "|draft2019-09|uri-template.json" ,
9696 "|draft7|uri-template.json" ,
97- "|draft6|uri-template.json" ,
98-
99- // Not supported
100- "|draft2020-12|uuid.json" ,
101- "|draft2019-09|uuid.json"
97+ "|draft6|uri-template.json"
10298] ) ;
10399
104100const shouldSkip = ( path : string [ ] ) : boolean => {
Original file line number Diff line number Diff line change 1+ const hexDigit = `[0-9a-fA-F]` ;
2+ const hexOctet = `(?:${ hexDigit } {2})` ;
3+ const timeLow = `${ hexOctet } {4}` ;
4+ const timeMid = `${ hexOctet } {2}` ;
5+ const timeHighAndVersion = `${ hexOctet } {2}` ;
6+ const clockSeqAndReserved = hexOctet ;
7+ const clockSeqLow = hexOctet ;
8+ const node = `${ hexOctet } {6}` ;
9+
10+ const uuid = `${ timeLow } \\-${ timeMid } \\-${ timeHighAndVersion } \\-${ clockSeqAndReserved } ${ clockSeqLow } \\-${ node } ` ;
11+
12+ export const isUuid = RegExp . prototype . test . bind ( new RegExp ( `^${ uuid } $` ) ) ;
13+
14+ export default {
15+ id : "https://json-schema.org/format/uuid" ,
16+ handler : ( uuid ) => typeof uuid !== "string" || isUuid ( uuid )
17+ } ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import uri from "./handlers/uri.js";
1010import uriReference from "./handlers/uri-reference.js" ;
1111import iri from "./handlers/iri.js" ;
1212import iriReference from "./handlers/iri-reference.js" ;
13+ import uuid from "./handlers/uuid.js" ;
1314
1415
1516addFormat ( dateTime ) ;
@@ -22,6 +23,7 @@ addFormat(uri);
2223addFormat ( uriReference ) ;
2324addFormat ( iri ) ;
2425addFormat ( iriReference ) ;
26+ addFormat ( uuid ) ;
2527
2628export {
2729 getShouldValidateFormat ,
You can’t perform that action at this time.
0 commit comments