Skip to content

Commit 8fff9b9

Browse files
Merge pull request #8 from relogiclabs/develop
Refactor and Optimize Source Code
2 parents 058fc2d + f407a9f commit 8fff9b9

File tree

250 files changed

+865
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+865
-806
lines changed

doc/content/articles/quickstart.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ Here is the error as displayed in the console. More specific errors will be list
124124
Schema (Line: 6:31) Json (Line: 3:14) [DTYP04]: Data type mismatch. Data type #integer is expected but found #string inferred by "not number".
125125
Schema (Line: 6:14) Json (Line: 3:14) [FUNC03]: Function @range(1, 10000) is incompatible with the target data type. Applying to a supported data type such as #number is expected but applied to an unsupported data type #string of "not number".
126126
Schema (Line: 8:20) Json (Line: 4:20) [REGX01]: Regex pattern does not match. String of pattern "[a-z_]{3,30}" is expected but found "john doe" that mismatches with pattern.
127-
Schema (Line: 5:12) Json (Line: 2:12) [VALD01]: Validation failed. Value {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, "register...ing, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}} is expected but found {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "profile":...: "123 Some St", "city": "Some town", "country": "Some Country"}}}.
128-
Schema (Line: 4:0) Json (Line: 1:0) [VALD01]: Validation failed. Value {"user": {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, ...ng, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}}} is expected but found {"user": {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "... "123 Some St", "city": "Some town", "country": "Some Country"}}}}.
127+
Schema (Line: 5:12) Json (Line: 2:12) [VALD01]: Validation failed. A valid value of {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, "register...ing, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}} is expected but found {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "profile":...: "123 Some St", "city": "Some town", "country": "Some Country"}}}.
128+
Schema (Line: 4:0) Json (Line: 1:0) [VALD01]: Validation failed. A valid value of {"user": {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, ...ng, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}}} is expected but found {"user": {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "... "123 Some St", "city": "Some town", "country": "Some Country"}}}}.
129129
```
130130

131131
## Assertion for Validation
@@ -148,13 +148,13 @@ Expected (Schema Line: 6:31): data type #integer
148148
Actual (Json Line: 3:14): found #string inferred by "not number"
149149

150150
at com.relogiclabs.json.schema.tree.ExceptionRegistry.failWith(ExceptionRegistry.java:31)
151-
at com.relogiclabs.json.schema.type.JNode.failWith(JNode.java:75)
152-
at com.relogiclabs.json.schema.type.JValidator.matchDataType(JValidator.java:89)
153-
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:78)
151+
at com.relogiclabs.json.schema.type.JNode.failWith(JNode.java:73)
152+
at com.relogiclabs.json.schema.type.JValidator.matchDataType(JValidator.java:87)
153+
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:76)
154154
at com.relogiclabs.json.schema.type.JObject.match(JObject.java:57)
155-
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:73)
155+
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:71)
156156
at com.relogiclabs.json.schema.type.JObject.match(JObject.java:57)
157-
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:73)
157+
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:71)
158158
at com.relogiclabs.json.schema.type.JRoot.match(JRoot.java:50)
159159
at com.relogiclabs.json.schema.tree.SchemaTree.match(SchemaTree.java:33)
160160
at com.relogiclabs.json.schema.JsonAssert.isValid(JsonAssert.java:61)

doc/content/articles/sourcebuild.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ Here is the error as displayed in the console. More specific errors will be list
135135
Schema (Line: 6:31) Json (Line: 3:14) [DTYP04]: Data type mismatch. Data type #integer is expected but found #string inferred by "not number".
136136
Schema (Line: 6:14) Json (Line: 3:14) [FUNC03]: Function @range(1, 10000) is incompatible with the target data type. Applying to a supported data type such as #number is expected but applied to an unsupported data type #string of "not number".
137137
Schema (Line: 8:20) Json (Line: 4:20) [REGX01]: Regex pattern does not match. String of pattern "[a-z_]{3,30}" is expected but found "john doe" that mismatches with pattern.
138-
Schema (Line: 5:12) Json (Line: 2:12) [VALD01]: Validation failed. Value {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, "register...ing, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}} is expected but found {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "profile":...: "123 Some St", "city": "Some town", "country": "Some Country"}}}.
139-
Schema (Line: 4:0) Json (Line: 1:0) [VALD01]: Validation failed. Value {"user": {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, ...ng, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}}} is expected but found {"user": {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "... "123 Some St", "city": "Some town", "country": "Some Country"}}}}.
138+
Schema (Line: 5:12) Json (Line: 2:12) [VALD01]: Validation failed. A valid value of {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, "register...ing, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}} is expected but found {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "profile":...: "123 Some St", "city": "Some town", "country": "Some Country"}}}.
139+
Schema (Line: 4:0) Json (Line: 1:0) [VALD01]: Validation failed. A valid value of {"user": {"id": @range(1, 10000) #integer, "username": @regex("[a-z_]{3,30}") #string, "role": "user" #string, "isActive": #boolean, ...ng, "country": @regex("[A-Za-z ]{3,50}") #string} #object #null}}} is expected but found {"user": {"id": "not number", "username": "john doe", "role": "user", "isActive": true, "registeredAt": "2023-09-06T15:10:30.639Z", "... "123 Some St", "city": "Some town", "country": "Some Country"}}}}.
140140
```
141141

142142
## Assertion for Validation
@@ -159,13 +159,13 @@ Expected (Schema Line: 6:31): data type #integer
159159
Actual (Json Line: 3:14): found #string inferred by "not number"
160160

161161
at com.relogiclabs.json.schema.tree.ExceptionRegistry.failWith(ExceptionRegistry.java:31)
162-
at com.relogiclabs.json.schema.type.JNode.failWith(JNode.java:75)
163-
at com.relogiclabs.json.schema.type.JValidator.matchDataType(JValidator.java:89)
164-
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:78)
162+
at com.relogiclabs.json.schema.type.JNode.failWith(JNode.java:73)
163+
at com.relogiclabs.json.schema.type.JValidator.matchDataType(JValidator.java:87)
164+
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:76)
165165
at com.relogiclabs.json.schema.type.JObject.match(JObject.java:57)
166-
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:73)
166+
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:71)
167167
at com.relogiclabs.json.schema.type.JObject.match(JObject.java:57)
168-
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:73)
168+
at com.relogiclabs.json.schema.type.JValidator.match(JValidator.java:71)
169169
at com.relogiclabs.json.schema.type.JRoot.match(JRoot.java:50)
170170
at com.relogiclabs.json.schema.tree.SchemaTree.match(SchemaTree.java:33)
171171
at com.relogiclabs.json.schema.JsonAssert.isValid(JsonAssert.java:61)

doc/content/articles/validation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ A JSON Schema ensures the correctness and consistency of JSON documents, and it
3737
| 11 | `Undefined` | `!` |
3838
| 12 | `Undefined Optional` | `! ?` |
3939

40-
The syntax used in the 9th row of the table is valid, but not common in real-world scenarios. The constraint function and data type provide redundant validations, considering the validation for value is succeeded. It is generally recommended to specify the data type in all cases except in the previous scenario. Even though the functions may perform precise validations, they are typically designed to accept a broader range of data types. Therefore, specifying the data type not only makes the schema more unambiguous for readers, but also generates clear validation errors if the expected type of value is not received from the input document. For instance, the `@range` function is defined for all types of numeric input as well as dates and times. If you only accept integers for a particular field, the `@range` function without `#integer` data type cannot ensure this requirement.
40+
The syntax used in the 10th row of the table is valid, but not common in real-world scenarios. The constraint function and data type provide redundant validations, considering the validation for value is succeeded. It is generally recommended to specify the data type in all cases except in the previous scenario. Even though the functions may perform precise validations, they are typically designed to accept a broader range of data types. Therefore, specifying the data type not only makes the schema more unambiguous for readers, but also generates clear validation errors if the expected type of value is not received from the input document. For instance, the `@range` function is defined for all types of numeric input as well as dates and times. If you only accept integers for a particular field, the `@range` function without `#integer` data type cannot ensure this requirement.
4141

4242
Now, let's explore the components of this notation and their functionalities. In the context of the validation rule, `Value` refers to a specific input JSON value of the document. This value can be either a composite value (e.g., an object or an array) or a primitive value (e.g., a string or a number).
4343

doc/public/api/allclasses-index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>All Classes and Interfaces (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>All Classes and Interfaces (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="class index">
1010
<meta name="generator" content="javadoc/AllClassesIndexWriter">
1111
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">

doc/public/api/allpackages-index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>All Packages (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>All Packages (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="package index">
1010
<meta name="generator" content="javadoc/AllPackagesIndexWriter">
1111
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/JsonAssert.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>JsonAssert (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>JsonAssert (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="declaration: package: com.relogiclabs.json.schema, class: JsonAssert">
1010
<meta name="generator" content="javadoc/ClassWriterImpl">
1111
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/JsonSchema.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>JsonSchema (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>JsonSchema (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="declaration: package: com.relogiclabs.json.schema, class: JsonSchema">
1010
<meta name="generator" content="javadoc/ClassWriterImpl">
1111
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/class-use/JsonAssert.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>Uses of Class com.relogiclabs.json.schema.JsonAssert (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>Uses of Class com.relogiclabs.json.schema.JsonAssert (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="use: package: com.relogiclabs.json.schema, class: JsonAssert">
1010
<meta name="generator" content="javadoc/ClassUseWriter">
1111
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/class-use/JsonSchema.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>Uses of Class com.relogiclabs.json.schema.JsonSchema (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>Uses of Class com.relogiclabs.json.schema.JsonSchema (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="use: package: com.relogiclabs.json.schema, class: JsonSchema">
1010
<meta name="generator" content="javadoc/ClassUseWriter">
1111
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/collection/IndexMap.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>IndexMap (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>IndexMap (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="declaration: package: com.relogiclabs.json.schema.collection, interface: IndexMap">
1010
<meta name="generator" content="javadoc/ClassWriterImpl">
1111
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/collection/Keyable.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>Keyable (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>Keyable (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="declaration: package: com.relogiclabs.json.schema.collection, interface: Keyable">
1010
<meta name="generator" content="javadoc/ClassWriterImpl">
1111
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/collection/class-use/IndexMap.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>Uses of Interface com.relogiclabs.json.schema.collection.IndexMap (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>Uses of Interface com.relogiclabs.json.schema.collection.IndexMap (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="use: package: com.relogiclabs.json.schema.collection, interface: IndexMap">
1010
<meta name="generator" content="javadoc/ClassUseWriter">
1111
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/collection/class-use/Keyable.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>Uses of Interface com.relogiclabs.json.schema.collection.Keyable (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>Uses of Interface com.relogiclabs.json.schema.collection.Keyable (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="use: package: com.relogiclabs.json.schema.collection, interface: Keyable">
1010
<meta name="generator" content="javadoc/ClassUseWriter">
1111
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">

doc/public/api/com/relogiclabs/json/schema/collection/package-summary.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE HTML>
22
<html lang="en">
33
<head>
4-
<!-- Generated by javadoc (17) on Fri Dec 15 18:08:25 BDT 2023 -->
5-
<title>com.relogiclabs.json.schema.collection (New Json Schema 1.11.0 API)</title>
4+
<!-- Generated by javadoc (17) on Thu Dec 21 19:43:29 BDT 2023 -->
5+
<title>com.relogiclabs.json.schema.collection (New Json Schema 1.12.0 API)</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8-
<meta name="dc.created" content="2023-12-15">
8+
<meta name="dc.created" content="2023-12-21">
99
<meta name="description" content="declaration: package: com.relogiclabs.json.schema.collection">
1010
<meta name="generator" content="javadoc/PackageWriterImpl">
1111
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">

0 commit comments

Comments
 (0)