Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit ba1a92c

Browse files
committed
Re-introduce "format" keyword, with some differences
* Get rid of the "color" and "style" format attributes. * Specify the different instance types which can be validated by attributes. * Specify that if an instance is not of a type which the format attribute can validate, the validation MUST succeed. * "regex" is an ECMA 262 regular expression, remove "/perl5" since these dialects are not compatible (perl5 supports lookbehinds, ECMA 262 doesn't). * Remove paragraph allowing other format attributes to be specified.
1 parent c74ee28 commit ba1a92c

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

draft-04/schema

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
},
7070

7171
"pattern" : {
72-
"type" : "string"
72+
"type" : "string",
73+
"format": "regex"
7374
},
7475

7576
"items" : {
@@ -146,15 +147,18 @@
146147
},
147148

148149
"id" : {
149-
"type" : "string"
150+
"type" : "string",
151+
"format": "uri"
150152
},
151153

152154
"$ref" : {
153-
"type" : "string"
155+
"type" : "string",
156+
"format": "uri"
154157
},
155158

156159
"$schema" : {
157-
"type" : "string"
160+
"type" : "string",
161+
"format": "uri"
158162
},
159163

160164
"title" : {

draft-zyp-json-schema-04.xml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,39 @@ Content-Type: application/json;
463463
</list>
464464
</t>
465465
</section>
466-
466+
467+
<section title="format">
468+
<t>This property helps to refine the type of data, content type, or microformat an instance value must adhere to. A format
469+
attribute MAY be one of the values listed below, and if so, SHOULD adhere to the semantics describing for the format. A format
470+
SHOULD only be used to give meaning to primitive types (string, integer, number, or boolean). Validators MUST validate that the
471+
instance values conform to a format.</t>
472+
473+
<t>A format attribute only validates a defined set of primitive types. If the primitive type of the currently validated instance
474+
is not a member of this set, the instance MUST be considered valid for this keyword. All format attributes defined below are
475+
listed along with the primitive types they validate.</t>
476+
477+
<t>The following formats are predefined:
478+
479+
<list style="hanging">
480+
<t hangText="date-time"> (string) This SHOULD be a date in ISO 8601 format of YYYY-MM-DDThh:mm:ssZ in UTC time.
481+
This is the recommended form of date/timestamp.</t>
482+
<t hangText="date">(string) This SHOULD be a date in the format of YYYY-MM-DD. It is recommended that you use the
483+
"date-time" format instead of "date" unless you need to transfer only the date part.</t>
484+
<t hangText="time">(string) This SHOULD be a time in the format of hh:mm:ss. It is recommended that you use the
485+
"date-time" format instead of "time" unless you need to transfer only the time part.</t>
486+
<t hangText="utc-millisec">(number) This SHOULD be the difference, measured in milliseconds, between the
487+
specified time and midnight, 00:00 of January 1, 1970 UTC.</t>
488+
<t hangText="regex">(string) This SHOULD be an ECMA 262 (ie, JavaScript) regular expression.</t>
489+
<t hangText="phone">(string) This SHOULD be a phone number (format MAY follow E.123).</t>
490+
<t hangText="uri">(string) This value SHOULD be a URI.</t>
491+
<t hangText="email">(string) This SHOULD be an email address.</t>
492+
<t hangText="ip-address">(string) This SHOULD be an ip version 4 address.</t>
493+
<t hangText="ipv6">(string) This SHOULD be an ip version 6 address.</t>
494+
<t hangText="host-name">(string) This SHOULD be a host-name.</t>
495+
</list>
496+
</t>
497+
</section>
498+
467499
<section title="pattern" anchor="pattern">
468500
<t>When the instance value is a string, this provides a regular expression that a string instance MUST match in order to be valid. Regular expressions SHOULD follow the regular expression specification from ECMA 262/Perl 5</t>
469501
</section>

0 commit comments

Comments
 (0)