diff --git a/README.md b/README.md index 3ac6d5d..249fac5 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Let's explore an example of our schema for a typical JSON API response containin } } ``` -In the above example, two types of constraints are used: constraint functions (also referred to as validation functions, such as `@range(1, 10000)`) and constraint data types (also referred to as validation data types, such as `#integer`). All constraint functions begin with the `@` symbol, while all constraint data types start with `#`. C-style comments are also supported within the schema. In this example, `address` can be `null` (like an optional input for users) and if it is `null` then no constraints of `address` are applicable. The following JSON is one of the examples that will be successfully validated against the above schema. To start your journey with the JSON validation library, please consult the documentation available [here](https://relogiclabs.github.io/JsonSchema-Java/articles/intro). +In the above example, two types of constraints are used: constraint functions (also referred to as validation functions, such as `@range(1, 10000)`) and constraint data types (also referred to as validation data types, such as `#integer`). All constraint functions begin with the `@` symbol, while all constraint data types start with `#`. C-style comments are also supported within the schema. In this example, `address` can be `null` (like an optional input for users) and if it is `null` then no constraints of `address` are applicable. The following JSON is one of the examples that will be successfully validated against the above schema. To start your journey with the JSON validation library, please consult the documentation available [here](https://relogiclabs.github.io/JSchema-Java/articles/intro). ```json { "user": { @@ -63,7 +63,7 @@ In the above example, two types of constraints are used: constraint functions (a } ``` ## Extended Example -The next example represents an expanded version of the previous one, which brings more complexity. To effectively construct such schemas with multiple layers of nested structures, it's beneficial to have a fundamental understanding of this schema format. While the syntax may seem difficult at first, it becomes straightforward once you have a basic understanding of it. For more detailed information, reference documentation is available [here](https://relogiclabs.github.io/JsonSchema-Java/articles/intro). +The next example represents an expanded version of the previous one, which brings more complexity. To effectively construct such schemas with multiple layers of nested structures, it's beneficial to have a fundamental understanding of this schema format. While the syntax may seem difficult at first, it becomes straightforward once you have a basic understanding of it. For more detailed information, reference documentation is available [here](https://relogiclabs.github.io/JSchema-Java/articles/intro). ```cpp %title: "Extended User Profile Dashboard API Response" %version: 2.0.0 @@ -224,4 +224,4 @@ The subsequent JSON sample is an illustrative example that successfully validate } } ``` -For more information about the schema syntax format and library functionalities, please refer to the reference documentation [here](https://relogiclabs.github.io/JsonSchema-Java/api/index.html). \ No newline at end of file +For more information about the schema syntax format and library functionalities, please refer to the reference documentation [here](https://relogiclabs.github.io/JSchema-Java/api/index.html). \ No newline at end of file diff --git a/doc/content/_index.md b/doc/content/_index.md index ffbaec3..1dd48c8 100644 --- a/doc/content/_index.md +++ b/doc/content/_index.md @@ -7,5 +7,5 @@ date = 2023-10-08T09:38:53+06:00 The New JSON Schema prioritizes simplicity, conciseness, and readability, making it user-friendly and accessible without the need for extensive prior knowledge. It offers efficient read-write facilities, precise JSON document definition through various data types and functions, and extensibility to meet modern web service diverse requirements. For a comprehensive overview of this JSON Schema, we invite you to explore our dedicated post available [here](https://www.relogiclabs.com/p/json-schema.html).
diff --git a/doc/content/articles/datatypes.md b/doc/content/articles/datatypes.md index 2c5223a..0b34b71 100644 --- a/doc/content/articles/datatypes.md +++ b/doc/content/articles/datatypes.md @@ -80,13 +80,13 @@ The date-time data type serves as the parent data type for both date and time ty ``` ### The Date Data Type -The date data type accepts a string representation of a date, conforming to the ISO 8601 standard (date part only). This is the default configuration, which can be modified using the directive described [here](/JsonSchema-Java/articles/directives). It is a subtype of date-time type and thus also formatted as per the JSON string specification. Detailed explanations of the ISO 8601 standard can be found in this [document](https://www.iso.org/iso-8601-date-and-time-format.html). Furthermore, you can refer to this [document](/JsonSchema-Java/articles/datetime) for a detailed description of the date pattern associated with this data type. To define this data type in schema, use the following syntax: +The date data type accepts a string representation of a date, conforming to the ISO 8601 standard (date part only). This is the default configuration, which can be modified using the directive described [here](/JSchema-Java/articles/directives). It is a subtype of date-time type and thus also formatted as per the JSON string specification. Detailed explanations of the ISO 8601 standard can be found in this [document](https://www.iso.org/iso-8601-date-and-time-format.html). Furthermore, you can refer to this [document](/JSchema-Java/articles/datetime) for a detailed description of the date pattern associated with this data type. To define this data type in schema, use the following syntax: ```html #date ``` ### The Time Data Type -The time data type accepts a string representation of a time (including both date and time parts), in accordance with the ISO 8601 standard. This default configuration can be modified using the directive described [here](/JsonSchema-Java/articles/directives). Similar to the date data type, it is a subtype of date-time data type and thus also formatted as per the JSON string specification. Here is the ISO 8601 standard [document](https://www.iso.org/iso-8601-date-and-time-format.html), which contains detailed explanations. Furthermore, you can refer to this [document](/JsonSchema-Java/articles/datetime) for a detailed description of the date-time pattern associated with this data type. To define this data type in schema, use the following syntax: +The time data type accepts a string representation of a time (including both date and time parts), in accordance with the ISO 8601 standard. This default configuration can be modified using the directive described [here](/JSchema-Java/articles/directives). Similar to the date data type, it is a subtype of date-time data type and thus also formatted as per the JSON string specification. Here is the ISO 8601 standard [document](https://www.iso.org/iso-8601-date-and-time-format.html), which contains detailed explanations. Furthermore, you can refer to this [document](/JSchema-Java/articles/datetime) for a detailed description of the date-time pattern associated with this data type. To define this data type in schema, use the following syntax: ```html #time ``` diff --git a/doc/content/articles/directives.md b/doc/content/articles/directives.md index f3cae56..38ab0c3 100644 --- a/doc/content/articles/directives.md +++ b/doc/content/articles/directives.md @@ -43,13 +43,13 @@ The default value of this directive is `false`, which means that by default, und ``` ### Date Data Type Format -The `DateDataTypeFormat` pragma directive enables you to customize the default format of the `#date` data type. By default, the `#date` data type follows the ISO 8601 standard, precisely using the format `YYYY-MM-DD`. Additional details on date-time patterns and formats are available [here](/JsonSchema-Java/articles/datetime). The subsequent example illustrates the process of defining a customized date format for the `#date` data type: +The `DateDataTypeFormat` pragma directive enables you to customize the default format of the `#date` data type. By default, the `#date` data type follows the ISO 8601 standard, precisely using the format `YYYY-MM-DD`. Additional details on date-time patterns and formats are available [here](/JSchema-Java/articles/datetime). The subsequent example illustrates the process of defining a customized date format for the `#date` data type: ```js %pragma DateDataTypeFormat: "DD-MM-YYYY" ``` ### Time Data Type Format -To customize the default format of the `#time` data type, utilize the `TimeDataTypeFormat` pragma directive. By default, the `#time` data type follows the ISO 8601 standard, precisely in the format `YYYY-MM-DD'T'hh:mm:ss.FZZ`. Further information on date-time patterns and formats can be found [here](/JsonSchema-Java/articles/datetime). The following example demonstrates how to specify a customized time format for the `#time` data type: +To customize the default format of the `#time` data type, utilize the `TimeDataTypeFormat` pragma directive. By default, the `#time` data type follows the ISO 8601 standard, precisely in the format `YYYY-MM-DD'T'hh:mm:ss.FZZ`. Further information on date-time patterns and formats can be found [here](/JSchema-Java/articles/datetime). The following example demonstrates how to specify a customized time format for the `#time` data type: ```js %pragma TimeDataTypeFormat: "DD-MM-YYYY hh:mm:ss" ``` @@ -69,7 +69,7 @@ The `IgnoreObjectPropertyOrder` pragma directive provides a means to enforce a s ## Definition / Define Directive This feature in JSON schemas allows you to define a name for a component or fragment of schema or validation rules, which can be referenced from various parts of your schema. This means that if you encounter similar validation requirements in different sections of your schema, you can conveniently refer to the named component instead of duplicating the same validation rules. -By providing clear and descriptive names for these validation rules or sub-schemas, you can enhance the overall clarity and context of your schema. This clarity not only makes it easier to understand the structure and intent of the schema but also contributes to keeping your complex schema well-organized, concise, and more manageable. For more information about the schema component syntax and format, please refer to the documentation [here](/JsonSchema-Java/articles/components). +By providing clear and descriptive names for these validation rules or sub-schemas, you can enhance the overall clarity and context of your schema. This clarity not only makes it easier to understand the structure and intent of the schema but also contributes to keeping your complex schema well-organized, concise, and more manageable. For more information about the schema component syntax and format, please refer to the documentation [here](/JSchema-Java/articles/components). The name or alias of the directive is always start with `$` which also refers to that they are named fragment defined elsewhere in the schema. Here is a simple example of how to use this directive: ```js diff --git a/doc/content/articles/functions.md b/doc/content/articles/functions.md index bd3b5d3..b63cc39 100644 --- a/doc/content/articles/functions.md +++ b/doc/content/articles/functions.md @@ -179,12 +179,12 @@ Validates whether the `target` string is a valid phone number. It follows the IT ```stylus #string target - @date(pattern) ``` -Validates that the `target` string matches the date and time pattern specified by the `pattern` parameter. It fully supports the ISO 8601 date and time format. Beyond this standard, it also allows custom date and time formats, ensuring compatibility with various systems and meeting diverse users and businesses requirements. This [document](/JsonSchema-Java/articles/datetime) provides a comprehensive overview of the date-time custom patterns. +Validates that the `target` string matches the date and time pattern specified by the `pattern` parameter. It fully supports the ISO 8601 date and time format. Beyond this standard, it also allows custom date and time formats, ensuring compatibility with various systems and meeting diverse users and businesses requirements. This [document](/JSchema-Java/articles/datetime) provides a comprehensive overview of the date-time custom patterns. ``` #string target - @time(pattern) ``` -Both the `@date` and `@time` functions support a complete range of date-time patterns, enabling the precise definition of any date and time scenario. Therefore, these functions can be used interchangeably. When the sole consideration is the date or day of the month in a year, employing the `@date` function is the more convenient choice. In contrast, when it becomes necessary to specify a particular time on a date, the `@time` function is the more appropriate option. To learn more about date-time patterns, please refer to [this page](/JsonSchema-Java/articles/datetime). +Both the `@date` and `@time` functions support a complete range of date-time patterns, enabling the precise definition of any date and time scenario. Therefore, these functions can be used interchangeably. When the sole consideration is the date or day of the month in a year, employing the `@date` function is the more convenient choice. In contrast, when it becomes necessary to specify a particular time on a date, the `@time` function is the more appropriate option. To learn more about date-time patterns, please refer to [this page](/JSchema-Java/articles/datetime). ### Date and Time Range ```stylus diff --git a/doc/content/articles/intro.md b/doc/content/articles/intro.md index 4738f7e..a8cbea7 100644 --- a/doc/content/articles/intro.md +++ b/doc/content/articles/intro.md @@ -8,15 +8,15 @@ weight = 1 JSON, short for JavaScript Object Notation, is one of the most widely used data exchange formats that are both user-friendly and machine-readable. New JSON Schema is a practical tool for defining and validating the structure of JSON documents. It allows you to specify the expected format, data types, and constraints of JSON data. The following guides offer comprehensive details about the New JSON Schema. This document provides a list of links, each corresponding to a specific detail document available in this project.The date-time data type serves as the parent data type for both date and time types. It is a subtype of JSON string type and thus formatted as per the JSON string specification. It is not intended to be used directly in a schema, but it provides common functionality for both date and time types.
#datetime
The date data type accepts a string representation of a date, conforming to the ISO 8601 standard (date part only). This is the default configuration, which can be modified using the directive described here. It is a subtype of date-time type and thus also formatted as per the JSON string specification. Detailed explanations of the ISO 8601 standard can be found in this document. Furthermore, you can refer to this document for a detailed description of the date pattern associated with this data type. To define this data type in schema, use the following syntax:
+The date data type accepts a string representation of a date, conforming to the ISO 8601 standard (date part only). This is the default configuration, which can be modified using the directive described here. It is a subtype of date-time type and thus also formatted as per the JSON string specification. Detailed explanations of the ISO 8601 standard can be found in this document. Furthermore, you can refer to this document for a detailed description of the date pattern associated with this data type. To define this data type in schema, use the following syntax:
#date
The time data type accepts a string representation of a time (including both date and time parts), in accordance with the ISO 8601 standard. This default configuration can be modified using the directive described here. Similar to the date data type, it is a subtype of date-time data type and thus also formatted as per the JSON string specification. Here is the ISO 8601 standard document, which contains detailed explanations. Furthermore, you can refer to this document for a detailed description of the date-time pattern associated with this data type. To define this data type in schema, use the following syntax:
+The time data type accepts a string representation of a time (including both date and time parts), in accordance with the ISO 8601 standard. This default configuration can be modified using the directive described here. Similar to the date data type, it is a subtype of date-time data type and thus also formatted as per the JSON string specification. Here is the ISO 8601 standard document, which contains detailed explanations. Furthermore, you can refer to this document for a detailed description of the date-time pattern associated with this data type. To define this data type in schema, use the following syntax:
#time
The number data type serves as the parent data type for all numeric types accommodated by the schema, including integer, floating-point, and exponent-based numbers. It accepts any JSON numerical value in accordance with the JSON standard. The syntax for specifying the number type is as follows:
diff --git a/doc/public/articles/datetime/index.html b/doc/public/articles/datetime/index.html index 9af493d..f105599 100644 --- a/doc/public/articles/datetime/index.html +++ b/doc/public/articles/datetime/index.html @@ -1,9 +1,9 @@ - - - + + + -The default value of this directive is false
, which means that by default, undefined properties in the JSON document are not ignored, and validation errors will be raised for them. For example, the following usage of this directive instructs the validation process to ignore any undefined properties in the JSON document:
%pragma IgnoreUndefinedProperties: true
The DateDataTypeFormat
pragma directive enables you to customize the default format of the #date
data type. By default, the #date
data type follows the ISO 8601 standard, precisely using the format YYYY-MM-DD
. Additional details on date-time patterns and formats are available here. The subsequent example illustrates the process of defining a customized date format for the #date
data type:
The DateDataTypeFormat
pragma directive enables you to customize the default format of the #date
data type. By default, the #date
data type follows the ISO 8601 standard, precisely using the format YYYY-MM-DD
. Additional details on date-time patterns and formats are available here. The subsequent example illustrates the process of defining a customized date format for the #date
data type:
%pragma DateDataTypeFormat: "DD-MM-YYYY"
To customize the default format of the #time
data type, utilize the TimeDataTypeFormat
pragma directive. By default, the #time
data type follows the ISO 8601 standard, precisely in the format YYYY-MM-DD'T'hh:mm:ss.FZZ
. Further information on date-time patterns and formats can be found here. The following example demonstrates how to specify a customized time format for the #time
data type:
To customize the default format of the #time
data type, utilize the TimeDataTypeFormat
pragma directive. By default, the #time
data type follows the ISO 8601 standard, precisely in the format YYYY-MM-DD'T'hh:mm:ss.FZZ
. Further information on date-time patterns and formats can be found here. The following example demonstrates how to specify a customized time format for the #time
data type:
%pragma TimeDataTypeFormat: "DD-MM-YYYY hh:mm:ss"
The FloatingPointTolerance
pragma directive allows you to define the tolerance level for relative errors in floating-point numbers during calculations and computations carried out by the validation process. By default, this directive is set to 1E-10
, indicating a small tolerance. However, you have the flexibility to adjust this value to any desired number. To specify a custom tolerance value of 1E-07
, you can use the following notation as an example:
%pragma IgnoreObjectPropertyOrder: false
This feature in JSON schemas allows you to define a name for a component or fragment of schema or validation rules, which can be referenced from various parts of your schema. This means that if you encounter similar validation requirements in different sections of your schema, you can conveniently refer to the named component instead of duplicating the same validation rules.
-By providing clear and descriptive names for these validation rules or sub-schemas, you can enhance the overall clarity and context of your schema. This clarity not only makes it easier to understand the structure and intent of the schema but also contributes to keeping your complex schema well-organized, concise, and more manageable. For more information about the schema component syntax and format, please refer to the documentation here.
+By providing clear and descriptive names for these validation rules or sub-schemas, you can enhance the overall clarity and context of your schema. This clarity not only makes it easier to understand the structure and intent of the schema but also contributes to keeping your complex schema well-organized, concise, and more manageable. For more information about the schema component syntax and format, please refer to the documentation here.
The name or alias of the directive is always start with $
which also refers to that they are named fragment defined elsewhere in the schema. Here is a simple example of how to use this directive:
%define $product: {
"id": @length(2, 10) @regex("[a-z][a-z0-9]+") #string,
diff --git a/doc/public/articles/functions/index.html b/doc/public/articles/functions/index.html
index 043695a..f7638f0 100644
--- a/doc/public/articles/functions/index.html
+++ b/doc/public/articles/functions/index.html
@@ -1,9 +1,9 @@
-
-
-
+
+
+
-
+
Validates whether the target
string is a valid phone number. It follows the ITU-T E.163 and E.164 telephone number notation to determine the validity of the phone number. In addition to conforming to this standard, it recognizes all widely used national and international phone number formats, ensuring compatibility with a wide range of systems and user requirements.
#string target - @date(pattern)
-
Validates that the target
string matches the date and time pattern specified by the pattern
parameter. It fully supports the ISO 8601 date and time format. Beyond this standard, it also allows custom date and time formats, ensuring compatibility with various systems and meeting diverse users and businesses requirements. This document provides a comprehensive overview of the date-time custom patterns.
Validates that the target
string matches the date and time pattern specified by the pattern
parameter. It fully supports the ISO 8601 date and time format. Beyond this standard, it also allows custom date and time formats, ensuring compatibility with various systems and meeting diverse users and businesses requirements. This document provides a comprehensive overview of the date-time custom patterns.
#string target - @time(pattern)
-
Both the @date
and @time
functions support a complete range of date-time patterns, enabling the precise definition of any date and time scenario. Therefore, these functions can be used interchangeably. When the sole consideration is the date or day of the month in a year, employing the @date
function is the more convenient choice. In contrast, when it becomes necessary to specify a particular time on a date, the @time
function is the more appropriate option. To learn more about date-time patterns, please refer to this page.
Both the @date
and @time
functions support a complete range of date-time patterns, enabling the precise definition of any date and time scenario. Therefore, these functions can be used interchangeably. When the sole consideration is the date or day of the month in a year, employing the @date
function is the more convenient choice. In contrast, when it becomes necessary to specify a particular time on a date, the @time
function is the more appropriate option. To learn more about date-time patterns, please refer to this page.
#datetime target - @range(#string start, #string end)
Validates that the target
date-time satisfies the range requirement specified by the parameters. It checks that the target
date-time is from or after the start
date-time specified and simultaneously until and before the end
date-time specified. If not, a validation error will generate. The start
and end
parameters must be the string representation of the target
data type, which can either be a #date
or #time
type.
Introduction | +Introduction | |
Quick Start | +Quick Start | |
Validation Syntax | +Validation Syntax | |
Directives | +Directives | |
Specification | +Specification | |
Data Types | +Data Types | |
Functions | +Functions | |
Date and Time | +Date and Time | |
Components | +Components | |
Source Build | +Source Build |