diff --git a/SCHEMA-SPEC.md b/SCHEMA-SPEC.md index 42d7433..1b77d43 100644 --- a/SCHEMA-SPEC.md +++ b/SCHEMA-SPEC.md @@ -273,10 +273,16 @@ and property names when the `node-names` or `prop-names` options are activated. * `pattern`: Regex pattern or patterns to test prop values against. Specific regex syntax may be implementation-dependent. * `min-length`: Minimum length, if a string. * `max-length`: Maximum length, if a string. -* `format`: Intended data format, if the value is a string. Possible values are: +* `format`: Intended data format, if the value is a string. Reserved values are: * `date-time`: ISO8601 date/time format. * `time`: "Time" section of ISO8601. * `date`: "Date" section of ISO8601. + * `duration`: ISO8601 duration format. + * `decimal`: IEEE 754-2008 decimal string format. + * `currency`: ISO 4217 currency code. + * `country-2`: ISO 3166-1 alpha-2 country code. + * `country-3`: ISO 3166-1 alpha-3 country code. + * `country-subdivision`: ISO 3166-2 country subdivision code. * `email`: RFC5302 email address. * `idn-email`: RFC6531 internationalized email address. * `hostname`: RFC1132 internet hostname. @@ -300,6 +306,21 @@ and property names when the `node-names` or `prop-names` options are activated. * `>=`: Greater than or equal to. * `<`: Less than. * `<=`: Less than or equal to. +* `format`: Intended data format for numeric values. Reserved values are: + * `i8`: 8-bit signed integer + * `i16`: 16-bit signed integer + * `i32`: 32-bit signed integer + * `i64`: 64-bit signed integer + * `u8`: 8-bit unsigned integer + * `u16`: 16-bit unsigned integer + * `u32`: 32-bit unsigned integer + * `u64`: 64-bit unsigned integer + * `isize`: Platform-dependent signed integer + * `usize`: Platform-dependent unsigned integer + * `f32`: IEEE 754 single (32-bit) precision floating point number + * `f64`: IEEE 754 double (64-bit) precision floating point number + * `decimal64`: IEEE 754-2008 64-bit decimal floating point number + * `decimal128`: IEEE 754-2008 128-bit decimal floating point number ### `definitions` node diff --git a/SPEC.md b/SPEC.md index f0443d7..026ff1f 100644 --- a/SPEC.md +++ b/SPEC.md @@ -236,16 +236,29 @@ Platform-dependent integer types, both signed and unsigned: * `isize` * `usize` +#### Reserved Type Annotations for Numbers With Decimals: + IEEE 754 floating point numbers, both single (32) and double (64) precision: * `f32` * `f64` +IEEE 754-2008 decimal floating point numbers + +* `decimal64` +* `decimal128` + #### Reserved Type Annotations for Strings: * `date-time`: ISO8601 date/time format. * `time`: "Time" section of ISO8601. * `date`: "Date" section of ISO8601. +* `duration`: ISO8601 duration format. +* `decimal`: IEEE 754-2008 decimal string format. +* `currency`: ISO 4217 currency code. +* `country-2`: ISO 3166-1 alpha-2 country code. +* `country-3`: ISO 3166-1 alpha-3 country code. +* `country-subdivision`: ISO 3166-2 country subdivision code. * `email`: RFC5302 email address. * `idn-email`: RFC6531 internationalized email address. * `hostname`: RFC1132 internet hostname. diff --git a/examples/kdl-schema.kdl b/examples/kdl-schema.kdl index b9c11df..b9cbb01 100644 --- a/examples/kdl-schema.kdl +++ b/examples/kdl-schema.kdl @@ -263,13 +263,13 @@ document { type "number" } } - node "format" description="Intended data format, if the value is a string." { + node "format" description="Intended data format." { max 1 value { min 1 type "string" // https://json-schema.org/understanding-json-schema/reference/string.html#format - enum "date-time" "date" "time" "email" "idn-email" "hostname" "idn-hostname" "ipv4" "ipv6" "uri" "uri-reference" "iri", "iri-reference" "uri-template" "regex" "uuid" "kdl-query" + enum "date-time" "date" "time" "duration" "decimal" "currency" "country-2" "country-3" "country-subdivision" "email" "idn-email" "hostname" "idn-hostname" "ipv4" "ipv6" "uri" "uri-reference" "iri", "iri-reference" "uri-template" "regex" "uuid" "kdl-query" "i8" "i16" "i32" "i64" "u8" "u16" "u32" "u64" "isize" "usize" "f32" "f64" "decimal64" "decimal128" } } node "%" description="Only used for numeric values. Constrains them to be multiples of the given number(s)" {