@@ -17,8 +17,8 @@ function passwordSample(min, max) {
1717 return res ;
1818}
1919
20- function commonDateTimeSample ( min , max , omitTime ) {
21- let res = toRFCDateTime ( new Date ( '2019-08-24T14:15:22.123Z' ) , omitTime , false ) ;
20+ function commonDateTimeSample ( { min, max, omitTime, omitDate } ) {
21+ let res = toRFCDateTime ( new Date ( '2019-08-24T14:15:22.123Z' ) , omitTime , omitDate , false ) ;
2222 if ( res . length < min ) {
2323 console . warn ( `Using minLength = ${ min } is incorrect with format "date-time"` ) ;
2424 }
@@ -29,11 +29,15 @@ function commonDateTimeSample(min, max, omitTime) {
2929}
3030
3131function dateTimeSample ( min , max ) {
32- return commonDateTimeSample ( min , max ) ;
32+ return commonDateTimeSample ( { min, max, omitTime : false , omitDate : false } ) ;
3333}
3434
3535function dateSample ( min , max ) {
36- return commonDateTimeSample ( min , max , true ) ;
36+ return commonDateTimeSample ( { min, max, omitTime : true , omitDate : false } ) ;
37+ }
38+
39+ function timeSample ( min , max ) {
40+ return commonDateTimeSample ( { min, max, omitTime : false , omitDate : true } ) . slice ( 1 ) ;
3741}
3842
3943function defaultSample ( min , max ) {
@@ -60,21 +64,59 @@ function uriSample() {
6064 return 'http://example.com' ;
6165}
6266
67+ function uriReferenceSample ( ) {
68+ return '../dictionary' ;
69+ }
70+
71+ function uriTemplateSample ( ) {
72+ return 'http://example.com/{endpoint}' ;
73+ }
74+
75+ function iriSample ( ) {
76+ return 'http://example.com' ;
77+ }
78+
79+ function iriReferenceSample ( ) {
80+ return '../dictionary' ;
81+ }
82+
6383function uuidSample ( _min , _max , propertyName ) {
6484 return uuid ( propertyName || 'id' ) ;
6585}
6686
87+ function jsonPointerSample ( ) {
88+ return '/json/pointer' ;
89+ }
90+
91+ function relativeJsonPointerSample ( ) {
92+ return '1/relative/json/pointer' ;
93+ }
94+
95+ function regexSample ( ) {
96+ return '/regex/' ;
97+ }
98+
6799const stringFormats = {
68100 'email' : emailSample ,
101+ 'idn-email' : emailSample , // https://tools.ietf.org/html/rfc6531#section-3.3
69102 'password' : passwordSample ,
70103 'date-time' : dateTimeSample ,
71104 'date' : dateSample ,
105+ 'time' : timeSample , // full-time in https://tools.ietf.org/html/rfc3339#section-5.6
72106 'ipv4' : ipv4Sample ,
73107 'ipv6' : ipv6Sample ,
74108 'hostname' : hostnameSample ,
109+ 'idn-hostname' : hostnameSample , // https://tools.ietf.org/html/rfc5890#section-2.3.2.3
110+ 'iri' : iriSample , // https://tools.ietf.org/html/rfc3987
111+ 'iri-reference' : iriReferenceSample ,
75112 'uri' : uriSample ,
113+ 'uri-reference' : uriReferenceSample , // either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1
114+ 'uri-template' : uriTemplateSample ,
76115 'uuid' : uuidSample ,
77- 'default' : defaultSample
116+ 'default' : defaultSample ,
117+ 'json-pointer' : jsonPointerSample ,
118+ 'relative-json-pointer' : relativeJsonPointerSample , // https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
119+ 'regex' : regexSample ,
78120} ;
79121
80122export function sampleString ( schema , options , spec , context ) {
0 commit comments