diff --git a/pages/learn/getting-started-step-by-step/getting-started-step-by-step.md b/pages/learn/getting-started-step-by-step/getting-started-step-by-step.md index 82826f683..e7cdaeee9 100644 --- a/pages/learn/getting-started-step-by-step/getting-started-step-by-step.md +++ b/pages/learn/getting-started-step-by-step/getting-started-step-by-step.md @@ -581,5 +581,5 @@ A Validator is a tool that implements the JSON Schema specification. All validat ![How JSON Schema works](https://json-schema.org/img/json_schema.svg) -To try it yourself, please visit [Tools](https://json-schema.org/implementations#validators) and select the validator that better suit your needs, our use the editors available below and select the different Schemas and Instances and see the different validation results. +To try it yourself, please visit [Tools](https://json-schema.org/implementations#validators) and select the validator that better suit your needs, our use the editors available below to explore the different Schemas and Instances and see the different validation results. diff --git a/public/data/getting-started-examples.json b/public/data/getting-started-examples.json index 5bf4468a1..b723ab71d 100644 --- a/public/data/getting-started-examples.json +++ b/public/data/getting-started-examples.json @@ -34,5 +34,51 @@ "details": "This is a valid JSON instance for the provided JSON Schema" } ] + }, + + { + "name": "Enumerated values schema", + "default": false, + "file": "/data/getting-started-examples/schemas/enumerated.json", + "instances": [ + { + "name": "Valid instance", + "default": true, + "valid": true, + "file": "/data/getting-started-examples/instances/enumerated-ok.json", + "details": "This is a valid JSON instance for the provided JSON Schema" + } + ] + }, + + { + "name": "Regular expression schema", + "default": false, + "file": "/data/getting-started-examples/schemas/regex.json", + "instances": [ + { + "name": "Valid instance", + "default": true, + "valid": true, + "file": "/data/getting-started-examples/instances/regex-ok.json", + "details": "This is a valid JSON instance for the provided JSON Schema" + } + ] + }, + + { + "name": "Conditional validation with if-else schema", + "default": false, + "file": "/data/getting-started-examples/schemas/conditional.json", + "instances": [ + { + "name": "Valid instance", + "default": true, + "valid": true, + "file": "/data/getting-started-examples/instances/conditional-ok.json", + "details": "This is a valid JSON instance for the provided JSON Schema" + } + ] } + ] diff --git a/public/data/getting-started-examples/instances/conditional-ok.json b/public/data/getting-started-examples/instances/conditional-ok.json new file mode 100644 index 000000000..95e0d986b --- /dev/null +++ b/public/data/getting-started-examples/instances/conditional-ok.json @@ -0,0 +1,4 @@ +{ + "isMember": true, + "membershipNumber": "1234567890" + } \ No newline at end of file diff --git a/public/data/getting-started-examples/instances/enumerated-ok.json b/public/data/getting-started-examples/instances/enumerated-ok.json new file mode 100644 index 000000000..4ad5e5aed --- /dev/null +++ b/public/data/getting-started-examples/instances/enumerated-ok.json @@ -0,0 +1,3 @@ +{ + "data": [1, 2, 3] +} \ No newline at end of file diff --git a/public/data/getting-started-examples/instances/regex-ok.json b/public/data/getting-started-examples/instances/regex-ok.json new file mode 100644 index 000000000..6255bcc09 --- /dev/null +++ b/public/data/getting-started-examples/instances/regex-ok.json @@ -0,0 +1,3 @@ +{ + "code": "ABC-123" +} \ No newline at end of file diff --git a/public/data/getting-started-examples/schemas/conditional.json b/public/data/getting-started-examples/schemas/conditional.json new file mode 100644 index 000000000..10c924c4f --- /dev/null +++ b/public/data/getting-started-examples/schemas/conditional.json @@ -0,0 +1,39 @@ +{ + "$id": "https://example.com/conditional-validation-if-else.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Conditional Validation with If-Else", + "type": "object", + "properties": { + "isMember": { + "type": "boolean" + }, + "membershipNumber": { + "type": "string" + } + }, + "required": ["isMember"], + "if": { + "properties": { + "isMember": { + "const": true + } + } + }, + "then": { + "properties": { + "membershipNumber": { + "type": "string", + "minLength": 10, + "maxLength": 10 + } + } + }, + "else": { + "properties": { + "membershipNumber": { + "type": "string", + "minLength": 15 + } + } + } + } \ No newline at end of file diff --git a/public/data/getting-started-examples/schemas/enumerated.json b/public/data/getting-started-examples/schemas/enumerated.json new file mode 100644 index 000000000..c7e9e1588 --- /dev/null +++ b/public/data/getting-started-examples/schemas/enumerated.json @@ -0,0 +1,11 @@ +{ + "$id": "https://example.com/enumerated-values.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Enumerated Values", + "type": "object", + "properties": { + "data": { + "enum": [42, true, "hello", null, [1, 2, 3]] + } + } +} \ No newline at end of file diff --git a/public/data/getting-started-examples/schemas/regex.json b/public/data/getting-started-examples/schemas/regex.json new file mode 100644 index 000000000..7d23a0d87 --- /dev/null +++ b/public/data/getting-started-examples/schemas/regex.json @@ -0,0 +1,12 @@ +{ + "$id": "https://example.com/regex-pattern.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Regular Expression Pattern", + "type": "object", + "properties": { + "code": { + "type": "string", + "pattern": "^[A-Z]{3}-\\d{3}$" + } + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 72e8f7590..f405c1b26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -375,6 +375,11 @@ dependencies: tslib "^2.4.0" +"@types/file-saver@^2.0.7": + version "2.0.7" + resolved "https://registry.yarnpkg.com/@types/file-saver/-/file-saver-2.0.7.tgz#8dbb2f24bdc7486c54aa854eb414940bbd056f7d" + integrity sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A== + "@types/hast@^2.0.0": version "2.3.8" resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.8.tgz#4ac5caf38b262b7bd5ca3202dda71f0271635660" @@ -1016,6 +1021,11 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== +core-util-is@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + cross-spawn@^7.0.0, cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -1613,6 +1623,11 @@ file-entry-cache@^6.0.1: dependencies: flat-cache "^3.0.4" +file-saver@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/file-saver/-/file-saver-2.0.5.tgz#d61cfe2ce059f414d899e9dd6d4107ee25670c38" + integrity sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA== + fill-range@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" @@ -1910,6 +1925,11 @@ ignore@^5.1.1, ignore@^5.2.0, ignore@^5.2.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg== +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== + immer@^10.0.3: version "10.0.3" resolved "https://registry.yarnpkg.com/immer/-/immer-10.0.3.tgz#a8de42065e964aa3edf6afc282dfc7f7f34ae3c9" @@ -1936,7 +1956,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2: +inherits@2, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -2176,6 +2196,11 @@ isarray@^2.0.5: resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -2258,6 +2283,16 @@ json5@^1.0.2: object.assign "^4.1.4" object.values "^1.1.6" +jszip@^3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2" + integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g== + dependencies: + lie "~3.3.0" + pako "~1.0.2" + readable-stream "~2.3.6" + setimmediate "^1.0.5" + keyv@^4.5.3: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" @@ -2290,6 +2325,13 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +lie@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a" + integrity sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ== + dependencies: + immediate "~3.0.5" + lilconfig@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" @@ -2627,6 +2669,11 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +pako@~1.0.2: + version "1.0.11" + resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" + integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -2779,6 +2826,11 @@ prismjs@~1.27.0: resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.27.0.tgz#bb6ee3138a0b438a3653dd4d6ce0cc6510a45057" integrity sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA== +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + prop-types@^15.5.7, prop-types@^15.8.1: version "15.8.1" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" @@ -2855,6 +2907,19 @@ read-cache@^1.0.0: dependencies: pify "^2.3.0" +readable-stream@~2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" + integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -2973,6 +3038,11 @@ safe-array-concat@^1.0.1: has-symbols "^1.0.3" isarray "^2.0.5" +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + safe-regex-test@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" @@ -3040,6 +3110,11 @@ set-function-name@^2.0.0, set-function-name@^2.0.1: functions-have-names "^1.2.3" has-property-descriptors "^1.0.0" +setimmediate@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== + shebang-command@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" @@ -3189,6 +3264,13 @@ string.prototype.trimstart@^1.0.7: define-properties "^1.2.0" es-abstract "^1.22.1" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + "strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -3455,7 +3537,7 @@ use-sync-external-store@1.2.0: resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== -util-deprecate@^1.0.2: +util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==