Skip to content

Commit

Permalink
Merge pull request #4 from relogiclabs/develop
Browse files Browse the repository at this point in the history
Refactor and Optimize Code
  • Loading branch information
zhossain-info authored Nov 4, 2023
2 parents 3a046b8 + bf32061 commit 5505d4f
Show file tree
Hide file tree
Showing 325 changed files with 2,887 additions and 3,430 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 constraint or rule descriptors are used: constraint functions (also known as validation functions, such as `@range(1, 10000)`) and constraint data types (also known 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 permitted in the schema. Please note that `address` can be `null` (eg. 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 which can successfully validate 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/JsonSchema-Java/articles/intro).
```json
{
"user": {
Expand Down Expand Up @@ -130,7 +130,7 @@ The next example represents an expanded version of the previous one, which bring
}
}
```
The subsequent JSON sample is an illustrative example that successfully validates against the expanded schema mentioned earlier. Within this example, recurring JSON structure appear that can be validated through defining components. By reusing defined components, you can achieve a clear and concise schema when validating large JSON with repetitive structures instead of duplicating large and complex validation constraints across the schema. This improves the overall readability and maintainability of the schema.
The subsequent JSON sample is an illustrative example that successfully validates against the expanded schema mentioned earlier. Within this example, recurring JSON structures appear that can be validated by defining components or nested functions and data types. Besides, reusing simple component definitions, you can achieve a clear and concise schema when validating large JSON with repetitive structures instead of duplicating or referring to various structures across the schema. This improves the overall readability and maintainability of the schema.
```json
{
"user": {
Expand Down Expand Up @@ -219,4 +219,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).
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).
79 changes: 41 additions & 38 deletions doc/content/articles/datetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,49 @@ Date and time formats are defined using date and time pattern strings. Within th

Below, you will find a list of pattern letters and strings that are defined for date and time patterns. Please note that any characters within the 'A' to 'Z' and 'a' to 'z' range are reserved and should not be directly included in the pattern string.

| Pattern | Description | Example |
|---------|---------------------------------------|---------|
| G | Era period designator | AD |
| YYYY | Four digit year number | 1970 |
| YY | Two digit year number | 70 |
| MM | Month number in year (2 digit form) | 01 |
| MMMM | Full name of month | January |
| MMM | Short name of month | Jan |
| M | Month number in year (1-2 digit form) | 1, 01 |
| DDDD | Full name of day in week | Monday |
| DDD | Short name of day in week | Mon |
| DD | Day in month (2 digit form) | 01 |
| D | Day in month (1-2 digit form) | 1, 01 |
| t | AM/PM designator | AM, PM |
| hh | Hour in day (2 digit form) | 01, 12 |
| h | Hour in day (1-2 digit form) | 1, 01 |
| mm | Minute in hour (2 digit form) | 01, 20 |
| m | Minute in hour (1-2 digit form) | 1, 01 |
| ss | Second in minute (2 digit form) | 1, 01 |
| s | Second in minute (1-2 digit form) | 1, 01 |
| f | Tenths of a second | 1 |
| ff | Hundredths of a second | 11 |
| fff | Milliseconds of a second | 111 |
| ffff | Ten thousandths of a second | 1111 |
| fffff | Hundred thousandths of a second | 11111 |
| ffffff | Millionths of a second | 111111 |
| F | Fraction of a second upto 6 digits | 1, 111 |
| SN | Pattern | Description | Example |
|----|----------|---------------------------------------|-------------------------|
| 1 | `G` | Era period designator | `AD` |
| 2 | `YYYY` | Four digit year number | `1970` |
| 3 | `YY` | Two digit year number | `70` |
| 4 | `MM` | Month number in year (2 digit form) | `01` |
| 5 | `MMMM` | Full name of month | `January` |
| 6 | `MMM` | Short name of month | `Jan` |
| 7 | `M` | Month number in year (1-2 digit form) | `1`; `01` |
| 8 | `DDDD` | Full name of day in week | `Monday` |
| 9 | `DDD` | Short name of day in week | `Mon` |
| 10 | `DD` | Day in month (2 digit form) | `01` |
| 11 | `D` | Day in month (1-2 digit form) | `1`; `01` |
| 12 | `t` | AM/PM designator | `AM`; `PM` |
| 13 | `hh` | Hour in day (2 digit form) | `01`; `12` |
| 14 | `h` | Hour in day (1-2 digit form) | `1`; `01` |
| 15 | `mm` | Minute in hour (2 digit form) | `01`; `20` |
| 16 | `m` | Minute in hour (1-2 digit form) | `1`; `01` |
| 17 | `ss` | Second in minute (2 digit form) | `01`; `30` |
| 18 | `s` | Second in minute (1-2 digit form) | `1`; `01` |
| 19 | `f` | Tenths of a second | `1` |
| 20 | `ff` | Hundredths of a second | `11` |
| 21 | `fff` | Milliseconds of a second | `111` |
| 22 | `ffff` | Ten thousandths of a second | `1111` |
| 23 | `fffff` | Hundred thousandths of a second | `11111` |
| 24 | `ffffff` | Millionths of a second | `111111` |
| 25 | `F` | Fraction of a second upto 6 digits | `1`; `111`; `111111` |
| 26 | `Z` | Time zone hours only offset | `+06`; `-05`; `Z` |
| 27 | `ZZ` | Time zone hours and minutes offset | `+09:30`; `−03:30`; `Z` |
| 28 | `ZZZ` | Time zone hours and minutes offset | `+0930`; `−0330`; `Z` |

The pattern components listed above can be combined to create comprehensive and customized date and time patterns to accommodate all system and user requirements. The following table illustrates some examples of how different date-time pattern components can be combined.

| Combined Pattern | Example |
|-----------------------------|-------------------------------|
| YYYY-MM-DD | 2023-09-01 |
| YYYY-MM-DD'T'hh:mm:ss.fffZZ | 2023-09-01T14:35:10.123+06:00 |
| MMMM DD, YYYY G | January 01, 1980 AD |
| DDDD, D MMMM YYYY | Tuesday, 11 July 2023 |
| YYYY.MM.DD hh.mm.ss t | 1980.11.21 10.30.50 pm |
| DDD, D MMM YY hh:mm:ss ZZ | Sun, 4 Jul 99 12:08:56 -06:00 |
| hh:mm:ss t ZZ | 03:11:30 AM +06:00 |
| SN | Usage | Combined Pattern | Example |
|----|---------|-----------------------------|---------------------------------|
| 1 | `#date` | `YYYY-MM-DD` | `2023-09-01` |
| 2 | `#time` | `YYYY-MM-DD'T'hh:mm:ss.FZZ` | `2023-09-01T14:35:10.111+06:00` |
| 3 | `@date` | `MMMM DD, YYYY G` | `January 01, 1980 AD` |
| 4 | `@date` | `DDDD, D MMMM YYYY` | `Tuesday, 11 July 2023` |
| 5 | `@time` | `YYYY.MM.DD hh.mm.ss t` | `1980.11.21 10.30.50 pm` |
| 6 | `@time` | `DDD, D MMM YY hh:mm:ss ZZ` | `Sun, 4 Jul 99 12:08:56 -06:00` |
| 7 | `@time` | `hh:mm:ss t ZZ` | `03:11:30 AM +06:00` |

The first pattern in the table above adheres to the ISO 8601 date format and is used to validate the `#date` data type within the schema. The second pattern in the table follows the ISO 8601 format for date and time, validating the `#time` data type in the schema. Instead of explicitly specifying these patterns in the `@date` or `@time` functions, a more concise approach is to directly utilize the `#date` or `#time` type within the schema.
The first pattern in the table above adheres to the ISO 8601 date format and is used to validate the `#date` data type within the schema. The second pattern in the table follows the ISO 8601 format for date and time, validating the `#time` data type in the schema. Instead of explicitly specifying these patterns in the `@date` or `@time` functions, a more concise approach is to directly utilize the `#date` or `#time` type within the schema. Detailed explanations regarding the date and time format of the ISO 8601 standard are available in this [document](https://www.iso.org/iso-8601-date-and-time-format.html).

When the AM/PM designator is included in the date and time pattern, the presence of any hour format specifier indicates that the time is in the 12-hour clock format. Conversely, when the AM/PM designator is omitted, the presence of any hour format specifier indicates that the time is in the 24-hour clock format.
When the AM/PM designator is included in the date and time pattern, the presence of any hour format specifier indicates that the time is in the 12-hour clock format. Conversely, when the AM/PM designator is omitted, the presence of any hour format specifier indicates that the time is in the 24-hour clock format.
Loading

0 comments on commit 5505d4f

Please sign in to comment.