rj_schema 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rj_schema/rapidjson/CMakeLists.txt +9 -4
- data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +10 -0
- data/ext/rj_schema/rapidjson/appveyor.yml +22 -9
- data/ext/rj_schema/rapidjson/bin/data/abcde.txt +1 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/address.json +139 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/allOf_address.json +7 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/anyOf_address.json +7 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/oneOf_address.json +7 -0
- data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +2 -2
- data/ext/rj_schema/rapidjson/doc/dom.md +1 -0
- data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +1 -0
- data/ext/rj_schema/rapidjson/doc/faq.md +3 -3
- data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +8 -8
- data/ext/rj_schema/rapidjson/doc/internals.md +1 -1
- data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +2 -2
- data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +1 -1
- data/ext/rj_schema/rapidjson/doc/sax.md +1 -1
- data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +2 -2
- data/ext/rj_schema/rapidjson/doc/stream.md +1 -1
- data/ext/rj_schema/rapidjson/doc/tutorial.md +1 -1
- data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +7 -6
- data/ext/rj_schema/rapidjson/example/CMakeLists.txt +1 -0
- data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +118 -0
- data/ext/rj_schema/rapidjson/example/sortkeys/sortkeys.cpp +62 -0
- data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +6 -6
- data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/document.h +124 -35
- data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +49 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +56 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/clzll.h +71 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +3 -17
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +20 -13
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +4 -3
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +50 -35
- data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +63 -5
- data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +63 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +67 -53
- data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +318 -164
- data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +10 -10
- data/ext/rj_schema/rapidjson/readme.md +51 -1
- data/ext/rj_schema/rapidjson/readme.zh-cn.md +2 -2
- data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/perftest/perftest.h +1 -1
- data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +2 -2
- data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +75 -1
- data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +1 -0
- data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/clzlltest.cpp +34 -0
- data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +19 -19
- data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +45 -2
- data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +10 -10
- data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +8 -8
- data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +157 -16
- data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +113 -75
- data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +2 -1
- data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +593 -78
- data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +5 -5
- data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/unittest.h +4 -1
- data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +12 -12
- data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/BUILD.bazel +175 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +18 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/CONTRIBUTING.md +160 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/LICENSE +28 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/Makefile.am +14 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +16 -35
- data/ext/rj_schema/rapidjson/thirdparty/gtest/WORKSPACE +8 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/appveyor.yml +104 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-autotools.sh +44 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-bazel.sh +36 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-linux.sh +41 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-osx.sh +40 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/get-nprocessors.sh +48 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-linux.sh +49 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-osx.sh +39 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/log-config.sh +51 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/travis.sh +44 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/configure.ac +16 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +72 -32
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +53 -42
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock.pc.in +9 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock_main.pc.in +9 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +4 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +6 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +117 -132
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +7 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +20 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +83 -26
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +262 -68
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +45 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +650 -366
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +76 -20
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +308 -229
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +18 -15
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +87 -26
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +33 -16
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +1209 -353
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +33 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +159 -88
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +3 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +16 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +71 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +7 -11
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +14 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +69 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +69 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +83 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +14 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +63 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +63 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +76 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +4 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +3 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +36 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +210 -135
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +108 -48
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +23 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/BUILD.bazel +123 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +166 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +64 -62
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +43 -18
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +11 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +91 -36
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +33 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +1286 -167
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +85 -83
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +102 -15
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +136 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +24 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +8 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +20 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +8 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +3 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +44 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +5 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +40 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +60 -31
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +232 -171
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest.pc.in +9 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest_main.pc.in +10 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +54 -16
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Pkgconfig.md +146 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +6 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{AdvancedGuide.md → advanced.md} +260 -26
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{FAQ.md → faq.md} +62 -57
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Primer.md → primer.md} +43 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Samples.md → samples.md} +0 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +53 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +30 -36
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +8 -17
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +140 -51
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +2 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +4 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +126 -30
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +6 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +8 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +6 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +4 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +13 -57
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +98 -59
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +34 -41
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +3 -10
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +9 -17
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +8 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +232 -99
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +3 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +17 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +17 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.sln +55 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj +149 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.sln +55 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj +149 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj +154 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj +162 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj +199 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters +26 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj +191 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters +26 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj +188 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj +180 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +6 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +0 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +7 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +5 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +3 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +10 -22
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +0 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +10 -10
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +226 -32
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +5 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +21 -29
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +85 -67
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +93 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +1 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +1 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +622 -164
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/BUILD.bazel +396 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +12 -15
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +2 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +6 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +1 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +84 -29
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +1 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +11 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +165 -63
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +13 -13
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_assert_by_exception_test.cc +119 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +1 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +0 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +6 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +0 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +20 -18
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_outfiles_test.py +162 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_output_unittest.py +611 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_test_utils.py +60 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +4 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +11 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +17 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +104 -66
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +2 -19
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +0 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +12 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test.py +65 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test_.cc +44 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +4 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +240 -149
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +0 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +0 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +15 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +100 -30
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +25 -23
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +4 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +47 -0
- data/ext/rj_schema/rapidjson/travis-doxygen.sh +13 -6
- data/ext/rj_schema/rj_schema.cpp +161 -17
- data/lib/rj_schema.rb +1 -1
- metadata +63 -58
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DevGuide.md +0 -132
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CheatSheet.md +0 -525
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CookBook.md +0 -3250
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/Documentation.md +0 -11
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/ForDummies.md +0 -439
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/FrequentlyAskedQuestions.md +0 -624
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CheatSheet.md +0 -534
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CookBook.md +0 -3342
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/Documentation.md +0 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/ForDummies.md +0 -439
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/FrequentlyAskedQuestions.md +0 -628
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CheatSheet.md +0 -556
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CookBook.md +0 -3432
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/Documentation.md +0 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/ForDummies.md +0 -439
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/FrequentlyAskedQuestions.md +0 -628
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/DevGuide.md +0 -126
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Documentation.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_AdvancedGuide.md +0 -2096
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Documentation.md +0 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_FAQ.md +0 -886
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Primer.md +0 -497
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_PumpManual.md +0 -177
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_XcodeGuide.md +0 -93
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_AdvancedGuide.md +0 -2178
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Documentation.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_FAQ.md +0 -1038
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Primer.md +0 -501
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_PumpManual.md +0 -177
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Samples.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_XcodeGuide.md +0 -93
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_AdvancedGuide.md +0 -2181
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Documentation.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_FAQ.md +0 -1082
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Primer.md +0 -501
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_PumpManual.md +0 -177
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Samples.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_XcodeGuide.md +0 -93
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.sln +0 -45
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.vcproj +0 -126
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.sln +0 -45
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.vcproj +0 -126
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main-md.vcproj +0 -129
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main.vcproj +0 -129
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test-md.vcproj +0 -164
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test.vcproj +0 -164
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest-md.vcproj +0 -147
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest.vcproj +0 -147
- data/ext/rj_schema/rapidjson/thirdparty/gtest/travis.sh +0 -15
@@ -18,6 +18,7 @@
|
|
18
18
|
#include "document.h"
|
19
19
|
#include "pointer.h"
|
20
20
|
#include "stringbuffer.h"
|
21
|
+
#include "error/en.h"
|
21
22
|
#include <cmath> // abs, floor
|
22
23
|
|
23
24
|
#if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX)
|
@@ -113,13 +114,36 @@ inline void PrintValidatorPointers(unsigned depth, const wchar_t* s, const wchar
|
|
113
114
|
#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword)
|
114
115
|
#endif
|
115
116
|
|
116
|
-
#define RAPIDJSON_INVALID_KEYWORD_RETURN(
|
117
|
+
#define RAPIDJSON_INVALID_KEYWORD_RETURN(code)\
|
117
118
|
RAPIDJSON_MULTILINEMACRO_BEGIN\
|
118
|
-
context.
|
119
|
-
|
119
|
+
context.invalidCode = code;\
|
120
|
+
context.invalidKeyword = SchemaType::GetValidateErrorKeyword(code).GetString();\
|
121
|
+
RAPIDJSON_INVALID_KEYWORD_VERBOSE(context.invalidKeyword);\
|
120
122
|
return false;\
|
121
123
|
RAPIDJSON_MULTILINEMACRO_END
|
122
124
|
|
125
|
+
///////////////////////////////////////////////////////////////////////////////
|
126
|
+
// ValidateFlag
|
127
|
+
|
128
|
+
/*! \def RAPIDJSON_VALIDATE_DEFAULT_FLAGS
|
129
|
+
\ingroup RAPIDJSON_CONFIG
|
130
|
+
\brief User-defined kValidateDefaultFlags definition.
|
131
|
+
|
132
|
+
User can define this as any \c ValidateFlag combinations.
|
133
|
+
*/
|
134
|
+
#ifndef RAPIDJSON_VALIDATE_DEFAULT_FLAGS
|
135
|
+
#define RAPIDJSON_VALIDATE_DEFAULT_FLAGS kValidateNoFlags
|
136
|
+
#endif
|
137
|
+
|
138
|
+
//! Combination of validate flags
|
139
|
+
/*! \see
|
140
|
+
*/
|
141
|
+
enum ValidateFlag {
|
142
|
+
kValidateNoFlags = 0, //!< No flags are set.
|
143
|
+
kValidateContinueOnErrorFlag = 1, //!< Don't stop after first validation error.
|
144
|
+
kValidateDefaultFlags = RAPIDJSON_VALIDATE_DEFAULT_FLAGS //!< Default validate flags. Can be customized by defining RAPIDJSON_VALIDATE_DEFAULT_FLAGS
|
145
|
+
};
|
146
|
+
|
123
147
|
///////////////////////////////////////////////////////////////////////////////
|
124
148
|
// Forward declarations
|
125
149
|
|
@@ -138,6 +162,8 @@ class ISchemaValidator {
|
|
138
162
|
public:
|
139
163
|
virtual ~ISchemaValidator() {}
|
140
164
|
virtual bool IsValid() const = 0;
|
165
|
+
virtual void SetValidateFlags(unsigned flags) = 0;
|
166
|
+
virtual unsigned GetValidateFlags() const = 0;
|
141
167
|
};
|
142
168
|
|
143
169
|
///////////////////////////////////////////////////////////////////////////////
|
@@ -147,7 +173,7 @@ template <typename SchemaType>
|
|
147
173
|
class ISchemaStateFactory {
|
148
174
|
public:
|
149
175
|
virtual ~ISchemaStateFactory() {}
|
150
|
-
virtual ISchemaValidator* CreateSchemaValidator(const SchemaType
|
176
|
+
virtual ISchemaValidator* CreateSchemaValidator(const SchemaType&, const bool inheritContinueOnErrors) = 0;
|
151
177
|
virtual void DestroySchemaValidator(ISchemaValidator* validator) = 0;
|
152
178
|
virtual void* CreateHasher() = 0;
|
153
179
|
virtual uint64_t GetHashCode(void* hasher) = 0;
|
@@ -201,13 +227,13 @@ public:
|
|
201
227
|
virtual void AddDependencySchemaError(const SValue& souceName, ISchemaValidator* subvalidator) = 0;
|
202
228
|
virtual bool EndDependencyErrors() = 0;
|
203
229
|
|
204
|
-
virtual void DisallowedValue() = 0;
|
230
|
+
virtual void DisallowedValue(const ValidateErrorCode code) = 0;
|
205
231
|
virtual void StartDisallowedType() = 0;
|
206
232
|
virtual void AddExpectedType(const typename SchemaType::ValueType& expectedType) = 0;
|
207
233
|
virtual void EndDisallowedType(const typename SchemaType::ValueType& actualType) = 0;
|
208
234
|
virtual void NotAllOf(ISchemaValidator** subvalidators, SizeType count) = 0;
|
209
235
|
virtual void NoneOf(ISchemaValidator** subvalidators, SizeType count) = 0;
|
210
|
-
virtual void NotOneOf(ISchemaValidator** subvalidators, SizeType count) = 0;
|
236
|
+
virtual void NotOneOf(ISchemaValidator** subvalidators, SizeType count, bool matched) = 0;
|
211
237
|
virtual void Disallowed() = 0;
|
212
238
|
};
|
213
239
|
|
@@ -332,6 +358,7 @@ struct SchemaValidationContext {
|
|
332
358
|
schema(s),
|
333
359
|
valueSchema(),
|
334
360
|
invalidKeyword(),
|
361
|
+
invalidCode(),
|
335
362
|
hasher(),
|
336
363
|
arrayElementHashCodes(),
|
337
364
|
validators(),
|
@@ -372,6 +399,7 @@ struct SchemaValidationContext {
|
|
372
399
|
const SchemaType* schema;
|
373
400
|
const SchemaType* valueSchema;
|
374
401
|
const Ch* invalidKeyword;
|
402
|
+
ValidateErrorCode invalidCode;
|
375
403
|
void* hasher; // Only validator access
|
376
404
|
void* arrayElementHashCodes; // Only validator access this
|
377
405
|
ISchemaValidator** validators;
|
@@ -409,7 +437,7 @@ public:
|
|
409
437
|
Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator) :
|
410
438
|
allocator_(allocator),
|
411
439
|
uri_(schemaDocument->GetURI(), *allocator),
|
412
|
-
pointer_(p),
|
440
|
+
pointer_(p, allocator),
|
413
441
|
typeless_(schemaDocument->GetTypeless()),
|
414
442
|
enum_(),
|
415
443
|
enumCount_(),
|
@@ -443,7 +471,6 @@ public:
|
|
443
471
|
exclusiveMaximum_(false),
|
444
472
|
defaultValueLength_(0)
|
445
473
|
{
|
446
|
-
typedef typename SchemaDocumentType::ValueType ValueType;
|
447
474
|
typedef typename ValueType::ConstValueIterator ConstValueIterator;
|
448
475
|
typedef typename ValueType::ConstMemberIterator ConstMemberIterator;
|
449
476
|
|
@@ -459,7 +486,7 @@ public:
|
|
459
486
|
AddType(*itr);
|
460
487
|
}
|
461
488
|
|
462
|
-
if (const ValueType* v = GetMember(value, GetEnumString()))
|
489
|
+
if (const ValueType* v = GetMember(value, GetEnumString())) {
|
463
490
|
if (v->IsArray() && v->Size() > 0) {
|
464
491
|
enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size()));
|
465
492
|
for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {
|
@@ -471,6 +498,7 @@ public:
|
|
471
498
|
enum_[enumCount_++] = h.GetHashCode();
|
472
499
|
}
|
473
500
|
}
|
501
|
+
}
|
474
502
|
|
475
503
|
if (schemaDocument) {
|
476
504
|
AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document);
|
@@ -689,7 +717,11 @@ public:
|
|
689
717
|
context.valueSchema = typeless_;
|
690
718
|
else {
|
691
719
|
context.error_handler.DisallowedItem(context.arrayElementIndex);
|
692
|
-
|
720
|
+
// Must set valueSchema for when kValidateContinueOnErrorFlag is set, else reports spurious type error
|
721
|
+
context.valueSchema = typeless_;
|
722
|
+
// Must bump arrayElementIndex for when kValidateContinueOnErrorFlag is set
|
723
|
+
context.arrayElementIndex++;
|
724
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAdditionalItems);
|
693
725
|
}
|
694
726
|
}
|
695
727
|
else
|
@@ -701,6 +733,7 @@ public:
|
|
701
733
|
}
|
702
734
|
|
703
735
|
RAPIDJSON_FORCEINLINE bool EndValue(Context& context) const {
|
736
|
+
// Only check pattern properties if we have validators
|
704
737
|
if (context.patternPropertiesValidatorCount > 0) {
|
705
738
|
bool otherValid = false;
|
706
739
|
SizeType count = context.patternPropertiesValidatorCount;
|
@@ -717,66 +750,70 @@ public:
|
|
717
750
|
if (context.objectPatternValidatorType == Context::kPatternValidatorOnly) {
|
718
751
|
if (!patternValid) {
|
719
752
|
context.error_handler.PropertyViolations(context.patternPropertiesValidators, count);
|
720
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
753
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorPatternProperties);
|
721
754
|
}
|
722
755
|
}
|
723
756
|
else if (context.objectPatternValidatorType == Context::kPatternValidatorWithProperty) {
|
724
757
|
if (!patternValid || !otherValid) {
|
725
758
|
context.error_handler.PropertyViolations(context.patternPropertiesValidators, count + 1);
|
726
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
759
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorPatternProperties);
|
727
760
|
}
|
728
761
|
}
|
729
762
|
else if (!patternValid && !otherValid) { // kPatternValidatorWithAdditionalProperty)
|
730
763
|
context.error_handler.PropertyViolations(context.patternPropertiesValidators, count + 1);
|
731
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
764
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorPatternProperties);
|
732
765
|
}
|
733
766
|
}
|
734
767
|
|
735
|
-
if
|
768
|
+
// For enums only check if we have a hasher
|
769
|
+
if (enum_ && context.hasher) {
|
736
770
|
const uint64_t h = context.factory.GetHashCode(context.hasher);
|
737
771
|
for (SizeType i = 0; i < enumCount_; i++)
|
738
772
|
if (enum_[i] == h)
|
739
773
|
goto foundEnum;
|
740
|
-
context.error_handler.DisallowedValue();
|
741
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
774
|
+
context.error_handler.DisallowedValue(kValidateErrorEnum);
|
775
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorEnum);
|
742
776
|
foundEnum:;
|
743
777
|
}
|
744
778
|
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
779
|
+
// Only check allOf etc if we have validators
|
780
|
+
if (context.validatorCount > 0) {
|
781
|
+
if (allOf_.schemas)
|
782
|
+
for (SizeType i = allOf_.begin; i < allOf_.begin + allOf_.count; i++)
|
783
|
+
if (!context.validators[i]->IsValid()) {
|
784
|
+
context.error_handler.NotAllOf(&context.validators[allOf_.begin], allOf_.count);
|
785
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAllOf);
|
786
|
+
}
|
787
|
+
|
788
|
+
if (anyOf_.schemas) {
|
789
|
+
for (SizeType i = anyOf_.begin; i < anyOf_.begin + anyOf_.count; i++)
|
790
|
+
if (context.validators[i]->IsValid())
|
791
|
+
goto foundAny;
|
792
|
+
context.error_handler.NoneOf(&context.validators[anyOf_.begin], anyOf_.count);
|
793
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAnyOf);
|
794
|
+
foundAny:;
|
795
|
+
}
|
796
|
+
|
797
|
+
if (oneOf_.schemas) {
|
798
|
+
bool oneValid = false;
|
799
|
+
for (SizeType i = oneOf_.begin; i < oneOf_.begin + oneOf_.count; i++)
|
800
|
+
if (context.validators[i]->IsValid()) {
|
801
|
+
if (oneValid) {
|
802
|
+
context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count, true);
|
803
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorOneOfMatch);
|
804
|
+
} else
|
805
|
+
oneValid = true;
|
806
|
+
}
|
807
|
+
if (!oneValid) {
|
808
|
+
context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count, false);
|
809
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorOneOf);
|
770
810
|
}
|
771
|
-
if (!oneValid) {
|
772
|
-
context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count);
|
773
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString());
|
774
811
|
}
|
775
|
-
}
|
776
812
|
|
777
|
-
|
778
|
-
|
779
|
-
|
813
|
+
if (not_ && context.validators[notValidatorIndex_]->IsValid()) {
|
814
|
+
context.error_handler.Disallowed();
|
815
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorNot);
|
816
|
+
}
|
780
817
|
}
|
781
818
|
|
782
819
|
return true;
|
@@ -785,7 +822,7 @@ public:
|
|
785
822
|
bool Null(Context& context) const {
|
786
823
|
if (!(type_ & (1 << kNullSchemaType))) {
|
787
824
|
DisallowedType(context, GetNullString());
|
788
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
825
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
789
826
|
}
|
790
827
|
return CreateParallelValidator(context);
|
791
828
|
}
|
@@ -793,7 +830,7 @@ public:
|
|
793
830
|
bool Bool(Context& context, bool) const {
|
794
831
|
if (!(type_ & (1 << kBooleanSchemaType))) {
|
795
832
|
DisallowedType(context, GetBooleanString());
|
796
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
833
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
797
834
|
}
|
798
835
|
return CreateParallelValidator(context);
|
799
836
|
}
|
@@ -825,7 +862,7 @@ public:
|
|
825
862
|
bool Double(Context& context, double d) const {
|
826
863
|
if (!(type_ & (1 << kNumberSchemaType))) {
|
827
864
|
DisallowedType(context, GetNumberString());
|
828
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
865
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
829
866
|
}
|
830
867
|
|
831
868
|
if (!minimum_.IsNull() && !CheckDoubleMinimum(context, d))
|
@@ -843,7 +880,7 @@ public:
|
|
843
880
|
bool String(Context& context, const Ch* str, SizeType length, bool) const {
|
844
881
|
if (!(type_ & (1 << kStringSchemaType))) {
|
845
882
|
DisallowedType(context, GetStringString());
|
846
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
883
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
847
884
|
}
|
848
885
|
|
849
886
|
if (minLength_ != 0 || maxLength_ != SizeType(~0)) {
|
@@ -851,18 +888,18 @@ public:
|
|
851
888
|
if (internal::CountStringCodePoint<EncodingType>(str, length, &count)) {
|
852
889
|
if (count < minLength_) {
|
853
890
|
context.error_handler.TooShort(str, length, minLength_);
|
854
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
891
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMinLength);
|
855
892
|
}
|
856
893
|
if (count > maxLength_) {
|
857
894
|
context.error_handler.TooLong(str, length, maxLength_);
|
858
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
895
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMaxLength);
|
859
896
|
}
|
860
897
|
}
|
861
898
|
}
|
862
899
|
|
863
900
|
if (pattern_ && !IsPatternMatch(pattern_, str, length)) {
|
864
901
|
context.error_handler.DoesNotMatch(str, length);
|
865
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
902
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorPattern);
|
866
903
|
}
|
867
904
|
|
868
905
|
return CreateParallelValidator(context);
|
@@ -871,7 +908,7 @@ public:
|
|
871
908
|
bool StartObject(Context& context) const {
|
872
909
|
if (!(type_ & (1 << kObjectSchemaType))) {
|
873
910
|
DisallowedType(context, GetObjectString());
|
874
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
911
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
875
912
|
}
|
876
913
|
|
877
914
|
if (hasDependencies_ || hasRequired_) {
|
@@ -899,7 +936,7 @@ public:
|
|
899
936
|
}
|
900
937
|
}
|
901
938
|
|
902
|
-
SizeType index;
|
939
|
+
SizeType index = 0;
|
903
940
|
if (FindPropertyIndex(ValueType(str, len).Move(), &index)) {
|
904
941
|
if (context.patternPropertiesSchemaCount > 0) {
|
905
942
|
context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = properties_[index].schema;
|
@@ -931,8 +968,10 @@ public:
|
|
931
968
|
}
|
932
969
|
|
933
970
|
if (context.patternPropertiesSchemaCount == 0) { // patternProperties are not additional properties
|
971
|
+
// Must set valueSchema for when kValidateContinueOnErrorFlag is set, else reports spurious type error
|
972
|
+
context.valueSchema = typeless_;
|
934
973
|
context.error_handler.DisallowedProperty(str, len);
|
935
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
974
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorAdditionalProperties);
|
936
975
|
}
|
937
976
|
|
938
977
|
return true;
|
@@ -946,17 +985,17 @@ public:
|
|
946
985
|
if (properties_[index].schema->defaultValueLength_ == 0 )
|
947
986
|
context.error_handler.AddMissingProperty(properties_[index].name);
|
948
987
|
if (context.error_handler.EndMissingProperties())
|
949
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
988
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorRequired);
|
950
989
|
}
|
951
990
|
|
952
991
|
if (memberCount < minProperties_) {
|
953
992
|
context.error_handler.TooFewProperties(memberCount, minProperties_);
|
954
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
993
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMinProperties);
|
955
994
|
}
|
956
995
|
|
957
996
|
if (memberCount > maxProperties_) {
|
958
997
|
context.error_handler.TooManyProperties(memberCount, maxProperties_);
|
959
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
998
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMaxProperties);
|
960
999
|
}
|
961
1000
|
|
962
1001
|
if (hasDependencies_) {
|
@@ -979,21 +1018,21 @@ public:
|
|
979
1018
|
}
|
980
1019
|
}
|
981
1020
|
if (context.error_handler.EndDependencyErrors())
|
982
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1021
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorDependencies);
|
983
1022
|
}
|
984
1023
|
|
985
1024
|
return true;
|
986
1025
|
}
|
987
1026
|
|
988
1027
|
bool StartArray(Context& context) const {
|
1028
|
+
context.arrayElementIndex = 0;
|
1029
|
+
context.inArray = true; // Ensure we note that we are in an array
|
1030
|
+
|
989
1031
|
if (!(type_ & (1 << kArraySchemaType))) {
|
990
1032
|
DisallowedType(context, GetArrayString());
|
991
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1033
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
992
1034
|
}
|
993
1035
|
|
994
|
-
context.arrayElementIndex = 0;
|
995
|
-
context.inArray = true;
|
996
|
-
|
997
1036
|
return CreateParallelValidator(context);
|
998
1037
|
}
|
999
1038
|
|
@@ -1002,17 +1041,55 @@ public:
|
|
1002
1041
|
|
1003
1042
|
if (elementCount < minItems_) {
|
1004
1043
|
context.error_handler.TooFewItems(elementCount, minItems_);
|
1005
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1044
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMinItems);
|
1006
1045
|
}
|
1007
1046
|
|
1008
1047
|
if (elementCount > maxItems_) {
|
1009
1048
|
context.error_handler.TooManyItems(elementCount, maxItems_);
|
1010
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1049
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMaxItems);
|
1011
1050
|
}
|
1012
1051
|
|
1013
1052
|
return true;
|
1014
1053
|
}
|
1015
1054
|
|
1055
|
+
static const ValueType& GetValidateErrorKeyword(ValidateErrorCode validateErrorCode) {
|
1056
|
+
switch (validateErrorCode) {
|
1057
|
+
case kValidateErrorMultipleOf: return GetMultipleOfString();
|
1058
|
+
case kValidateErrorMaximum: return GetMaximumString();
|
1059
|
+
case kValidateErrorExclusiveMaximum: return GetMaximumString(); // Same
|
1060
|
+
case kValidateErrorMinimum: return GetMinimumString();
|
1061
|
+
case kValidateErrorExclusiveMinimum: return GetMinimumString(); // Same
|
1062
|
+
|
1063
|
+
case kValidateErrorMaxLength: return GetMaxLengthString();
|
1064
|
+
case kValidateErrorMinLength: return GetMinLengthString();
|
1065
|
+
case kValidateErrorPattern: return GetPatternString();
|
1066
|
+
|
1067
|
+
case kValidateErrorMaxItems: return GetMaxItemsString();
|
1068
|
+
case kValidateErrorMinItems: return GetMinItemsString();
|
1069
|
+
case kValidateErrorUniqueItems: return GetUniqueItemsString();
|
1070
|
+
case kValidateErrorAdditionalItems: return GetAdditionalItemsString();
|
1071
|
+
|
1072
|
+
case kValidateErrorMaxProperties: return GetMaxPropertiesString();
|
1073
|
+
case kValidateErrorMinProperties: return GetMinPropertiesString();
|
1074
|
+
case kValidateErrorRequired: return GetRequiredString();
|
1075
|
+
case kValidateErrorAdditionalProperties: return GetAdditionalPropertiesString();
|
1076
|
+
case kValidateErrorPatternProperties: return GetPatternPropertiesString();
|
1077
|
+
case kValidateErrorDependencies: return GetDependenciesString();
|
1078
|
+
|
1079
|
+
case kValidateErrorEnum: return GetEnumString();
|
1080
|
+
case kValidateErrorType: return GetTypeString();
|
1081
|
+
|
1082
|
+
case kValidateErrorOneOf: return GetOneOfString();
|
1083
|
+
case kValidateErrorOneOfMatch: return GetOneOfString(); // Same
|
1084
|
+
case kValidateErrorAllOf: return GetAllOfString();
|
1085
|
+
case kValidateErrorAnyOf: return GetAnyOfString();
|
1086
|
+
case kValidateErrorNot: return GetNotString();
|
1087
|
+
|
1088
|
+
default: return GetNullString();
|
1089
|
+
}
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
|
1016
1093
|
// Generate functions for string literal according to Ch
|
1017
1094
|
#define RAPIDJSON_STRING_(name, ...) \
|
1018
1095
|
static const ValueType& Get##name##String() {\
|
@@ -1149,12 +1226,15 @@ private:
|
|
1149
1226
|
#elif RAPIDJSON_SCHEMA_USE_STDREGEX
|
1150
1227
|
template <typename ValueType>
|
1151
1228
|
RegexType* CreatePattern(const ValueType& value) {
|
1152
|
-
if (value.IsString())
|
1229
|
+
if (value.IsString()) {
|
1230
|
+
RegexType *r = static_cast<RegexType*>(allocator_->Malloc(sizeof(RegexType)));
|
1153
1231
|
try {
|
1154
|
-
return new (
|
1232
|
+
return new (r) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript);
|
1155
1233
|
}
|
1156
1234
|
catch (const std::regex_error&) {
|
1235
|
+
AllocatorType::Free(r);
|
1157
1236
|
}
|
1237
|
+
}
|
1158
1238
|
return 0;
|
1159
1239
|
}
|
1160
1240
|
|
@@ -1188,31 +1268,32 @@ private:
|
|
1188
1268
|
context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));
|
1189
1269
|
context.validatorCount = validatorCount_;
|
1190
1270
|
|
1271
|
+
// Always return after first failure for these sub-validators
|
1191
1272
|
if (allOf_.schemas)
|
1192
|
-
CreateSchemaValidators(context, allOf_);
|
1273
|
+
CreateSchemaValidators(context, allOf_, false);
|
1193
1274
|
|
1194
1275
|
if (anyOf_.schemas)
|
1195
|
-
CreateSchemaValidators(context, anyOf_);
|
1276
|
+
CreateSchemaValidators(context, anyOf_, false);
|
1196
1277
|
|
1197
1278
|
if (oneOf_.schemas)
|
1198
|
-
CreateSchemaValidators(context, oneOf_);
|
1279
|
+
CreateSchemaValidators(context, oneOf_, false);
|
1199
1280
|
|
1200
1281
|
if (not_)
|
1201
|
-
context.validators[notValidatorIndex_] = context.factory.CreateSchemaValidator(*not_);
|
1202
|
-
|
1282
|
+
context.validators[notValidatorIndex_] = context.factory.CreateSchemaValidator(*not_, false);
|
1283
|
+
|
1203
1284
|
if (hasSchemaDependencies_) {
|
1204
1285
|
for (SizeType i = 0; i < propertyCount_; i++)
|
1205
1286
|
if (properties_[i].dependenciesSchema)
|
1206
|
-
context.validators[properties_[i].dependenciesValidatorIndex] = context.factory.CreateSchemaValidator(*properties_[i].dependenciesSchema);
|
1287
|
+
context.validators[properties_[i].dependenciesValidatorIndex] = context.factory.CreateSchemaValidator(*properties_[i].dependenciesSchema, false);
|
1207
1288
|
}
|
1208
1289
|
}
|
1209
1290
|
|
1210
1291
|
return true;
|
1211
1292
|
}
|
1212
1293
|
|
1213
|
-
void CreateSchemaValidators(Context& context, const SchemaArray& schemas) const {
|
1294
|
+
void CreateSchemaValidators(Context& context, const SchemaArray& schemas, const bool inheritContinueOnErrors) const {
|
1214
1295
|
for (SizeType i = 0; i < schemas.count; i++)
|
1215
|
-
context.validators[schemas.begin + i] = context.factory.CreateSchemaValidator(*schemas.schemas[i]);
|
1296
|
+
context.validators[schemas.begin + i] = context.factory.CreateSchemaValidator(*schemas.schemas[i], inheritContinueOnErrors);
|
1216
1297
|
}
|
1217
1298
|
|
1218
1299
|
// O(n)
|
@@ -1232,19 +1313,19 @@ private:
|
|
1232
1313
|
bool CheckInt(Context& context, int64_t i) const {
|
1233
1314
|
if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) {
|
1234
1315
|
DisallowedType(context, GetIntegerString());
|
1235
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1316
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
1236
1317
|
}
|
1237
1318
|
|
1238
1319
|
if (!minimum_.IsNull()) {
|
1239
1320
|
if (minimum_.IsInt64()) {
|
1240
1321
|
if (exclusiveMinimum_ ? i <= minimum_.GetInt64() : i < minimum_.GetInt64()) {
|
1241
1322
|
context.error_handler.BelowMinimum(i, minimum_, exclusiveMinimum_);
|
1242
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1323
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum);
|
1243
1324
|
}
|
1244
1325
|
}
|
1245
1326
|
else if (minimum_.IsUint64()) {
|
1246
1327
|
context.error_handler.BelowMinimum(i, minimum_, exclusiveMinimum_);
|
1247
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1328
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum); // i <= max(int64_t) < minimum.GetUint64()
|
1248
1329
|
}
|
1249
1330
|
else if (!CheckDoubleMinimum(context, static_cast<double>(i)))
|
1250
1331
|
return false;
|
@@ -1254,7 +1335,7 @@ private:
|
|
1254
1335
|
if (maximum_.IsInt64()) {
|
1255
1336
|
if (exclusiveMaximum_ ? i >= maximum_.GetInt64() : i > maximum_.GetInt64()) {
|
1256
1337
|
context.error_handler.AboveMaximum(i, maximum_, exclusiveMaximum_);
|
1257
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1338
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum);
|
1258
1339
|
}
|
1259
1340
|
}
|
1260
1341
|
else if (maximum_.IsUint64()) { }
|
@@ -1267,7 +1348,7 @@ private:
|
|
1267
1348
|
if (multipleOf_.IsUint64()) {
|
1268
1349
|
if (static_cast<uint64_t>(i >= 0 ? i : -i) % multipleOf_.GetUint64() != 0) {
|
1269
1350
|
context.error_handler.NotMultipleOf(i, multipleOf_);
|
1270
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1351
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMultipleOf);
|
1271
1352
|
}
|
1272
1353
|
}
|
1273
1354
|
else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))
|
@@ -1280,14 +1361,14 @@ private:
|
|
1280
1361
|
bool CheckUint(Context& context, uint64_t i) const {
|
1281
1362
|
if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) {
|
1282
1363
|
DisallowedType(context, GetIntegerString());
|
1283
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1364
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorType);
|
1284
1365
|
}
|
1285
1366
|
|
1286
1367
|
if (!minimum_.IsNull()) {
|
1287
1368
|
if (minimum_.IsUint64()) {
|
1288
1369
|
if (exclusiveMinimum_ ? i <= minimum_.GetUint64() : i < minimum_.GetUint64()) {
|
1289
1370
|
context.error_handler.BelowMinimum(i, minimum_, exclusiveMinimum_);
|
1290
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1371
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum);
|
1291
1372
|
}
|
1292
1373
|
}
|
1293
1374
|
else if (minimum_.IsInt64())
|
@@ -1300,12 +1381,12 @@ private:
|
|
1300
1381
|
if (maximum_.IsUint64()) {
|
1301
1382
|
if (exclusiveMaximum_ ? i >= maximum_.GetUint64() : i > maximum_.GetUint64()) {
|
1302
1383
|
context.error_handler.AboveMaximum(i, maximum_, exclusiveMaximum_);
|
1303
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1384
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum);
|
1304
1385
|
}
|
1305
1386
|
}
|
1306
1387
|
else if (maximum_.IsInt64()) {
|
1307
1388
|
context.error_handler.AboveMaximum(i, maximum_, exclusiveMaximum_);
|
1308
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1389
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum); // i >= 0 > maximum_
|
1309
1390
|
}
|
1310
1391
|
else if (!CheckDoubleMaximum(context, static_cast<double>(i)))
|
1311
1392
|
return false;
|
@@ -1315,7 +1396,7 @@ private:
|
|
1315
1396
|
if (multipleOf_.IsUint64()) {
|
1316
1397
|
if (i % multipleOf_.GetUint64() != 0) {
|
1317
1398
|
context.error_handler.NotMultipleOf(i, multipleOf_);
|
1318
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1399
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMultipleOf);
|
1319
1400
|
}
|
1320
1401
|
}
|
1321
1402
|
else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))
|
@@ -1328,7 +1409,7 @@ private:
|
|
1328
1409
|
bool CheckDoubleMinimum(Context& context, double d) const {
|
1329
1410
|
if (exclusiveMinimum_ ? d <= minimum_.GetDouble() : d < minimum_.GetDouble()) {
|
1330
1411
|
context.error_handler.BelowMinimum(d, minimum_, exclusiveMinimum_);
|
1331
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1412
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum);
|
1332
1413
|
}
|
1333
1414
|
return true;
|
1334
1415
|
}
|
@@ -1336,7 +1417,7 @@ private:
|
|
1336
1417
|
bool CheckDoubleMaximum(Context& context, double d) const {
|
1337
1418
|
if (exclusiveMaximum_ ? d >= maximum_.GetDouble() : d > maximum_.GetDouble()) {
|
1338
1419
|
context.error_handler.AboveMaximum(d, maximum_, exclusiveMaximum_);
|
1339
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1420
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum);
|
1340
1421
|
}
|
1341
1422
|
return true;
|
1342
1423
|
}
|
@@ -1347,7 +1428,7 @@ private:
|
|
1347
1428
|
double r = a - q * b;
|
1348
1429
|
if (r > 0.0) {
|
1349
1430
|
context.error_handler.NotMultipleOf(d, multipleOf_);
|
1350
|
-
RAPIDJSON_INVALID_KEYWORD_RETURN(
|
1431
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorMultipleOf);
|
1351
1432
|
}
|
1352
1433
|
return true;
|
1353
1434
|
}
|
@@ -1761,8 +1842,7 @@ template <
|
|
1761
1842
|
class GenericSchemaValidator :
|
1762
1843
|
public internal::ISchemaStateFactory<typename SchemaDocumentType::SchemaType>,
|
1763
1844
|
public internal::ISchemaValidator,
|
1764
|
-
public internal::IValidationErrorHandler<typename SchemaDocumentType::SchemaType>
|
1765
|
-
{
|
1845
|
+
public internal::IValidationErrorHandler<typename SchemaDocumentType::SchemaType> {
|
1766
1846
|
public:
|
1767
1847
|
typedef typename SchemaDocumentType::SchemaType SchemaType;
|
1768
1848
|
typedef typename SchemaDocumentType::PointerType PointerType;
|
@@ -1795,7 +1875,8 @@ public:
|
|
1795
1875
|
error_(kObjectType),
|
1796
1876
|
currentError_(),
|
1797
1877
|
missingDependents_(),
|
1798
|
-
valid_(true)
|
1878
|
+
valid_(true),
|
1879
|
+
flags_(kValidateDefaultFlags)
|
1799
1880
|
#if RAPIDJSON_SCHEMA_VERBOSE
|
1800
1881
|
, depth_(0)
|
1801
1882
|
#endif
|
@@ -1826,7 +1907,8 @@ public:
|
|
1826
1907
|
error_(kObjectType),
|
1827
1908
|
currentError_(),
|
1828
1909
|
missingDependents_(),
|
1829
|
-
valid_(true)
|
1910
|
+
valid_(true),
|
1911
|
+
flags_(kValidateDefaultFlags)
|
1830
1912
|
#if RAPIDJSON_SCHEMA_VERBOSE
|
1831
1913
|
, depth_(0)
|
1832
1914
|
#endif
|
@@ -1844,31 +1926,61 @@ public:
|
|
1844
1926
|
while (!schemaStack_.Empty())
|
1845
1927
|
PopSchema();
|
1846
1928
|
documentStack_.Clear();
|
1929
|
+
ResetError();
|
1930
|
+
}
|
1931
|
+
|
1932
|
+
//! Reset the error state.
|
1933
|
+
void ResetError() {
|
1847
1934
|
error_.SetObject();
|
1848
1935
|
currentError_.SetNull();
|
1849
1936
|
missingDependents_.SetNull();
|
1850
1937
|
valid_ = true;
|
1851
1938
|
}
|
1852
1939
|
|
1940
|
+
//! Implementation of ISchemaValidator
|
1941
|
+
void SetValidateFlags(unsigned flags) {
|
1942
|
+
flags_ = flags;
|
1943
|
+
}
|
1944
|
+
virtual unsigned GetValidateFlags() const {
|
1945
|
+
return flags_;
|
1946
|
+
}
|
1947
|
+
|
1853
1948
|
//! Checks whether the current state is valid.
|
1854
1949
|
// Implementation of ISchemaValidator
|
1855
|
-
virtual bool IsValid() const {
|
1950
|
+
virtual bool IsValid() const {
|
1951
|
+
if (!valid_) return false;
|
1952
|
+
if (GetContinueOnErrors() && !error_.ObjectEmpty()) return false;
|
1953
|
+
return true;
|
1954
|
+
}
|
1856
1955
|
|
1857
1956
|
//! Gets the error object.
|
1858
1957
|
ValueType& GetError() { return error_; }
|
1859
1958
|
const ValueType& GetError() const { return error_; }
|
1860
1959
|
|
1861
1960
|
//! Gets the JSON pointer pointed to the invalid schema.
|
1961
|
+
// If reporting all errors, the stack will be empty.
|
1862
1962
|
PointerType GetInvalidSchemaPointer() const {
|
1863
1963
|
return schemaStack_.Empty() ? PointerType() : CurrentSchema().GetPointer();
|
1864
1964
|
}
|
1865
1965
|
|
1866
1966
|
//! Gets the keyword of invalid schema.
|
1967
|
+
// If reporting all errors, the stack will be empty, so return "errors".
|
1867
1968
|
const Ch* GetInvalidSchemaKeyword() const {
|
1868
|
-
|
1969
|
+
if (!schemaStack_.Empty()) return CurrentContext().invalidKeyword;
|
1970
|
+
if (GetContinueOnErrors() && !error_.ObjectEmpty()) return (const Ch*)GetErrorsString();
|
1971
|
+
return 0;
|
1972
|
+
}
|
1973
|
+
|
1974
|
+
//! Gets the error code of invalid schema.
|
1975
|
+
// If reporting all errors, the stack will be empty, so return kValidateErrors.
|
1976
|
+
ValidateErrorCode GetInvalidSchemaCode() const {
|
1977
|
+
if (!schemaStack_.Empty()) return CurrentContext().invalidCode;
|
1978
|
+
if (GetContinueOnErrors() && !error_.ObjectEmpty()) return kValidateErrors;
|
1979
|
+
return kValidateErrorNone;
|
1869
1980
|
}
|
1870
1981
|
|
1871
1982
|
//! Gets the JSON pointer pointed to the invalid value.
|
1983
|
+
// If reporting all errors, the stack will be empty.
|
1872
1984
|
PointerType GetInvalidDocumentPointer() const {
|
1873
1985
|
if (documentStack_.Empty()) {
|
1874
1986
|
return PointerType();
|
@@ -1879,64 +1991,64 @@ public:
|
|
1879
1991
|
}
|
1880
1992
|
|
1881
1993
|
void NotMultipleOf(int64_t actual, const SValue& expected) {
|
1882
|
-
AddNumberError(
|
1994
|
+
AddNumberError(kValidateErrorMultipleOf, ValueType(actual).Move(), expected);
|
1883
1995
|
}
|
1884
1996
|
void NotMultipleOf(uint64_t actual, const SValue& expected) {
|
1885
|
-
AddNumberError(
|
1997
|
+
AddNumberError(kValidateErrorMultipleOf, ValueType(actual).Move(), expected);
|
1886
1998
|
}
|
1887
1999
|
void NotMultipleOf(double actual, const SValue& expected) {
|
1888
|
-
AddNumberError(
|
2000
|
+
AddNumberError(kValidateErrorMultipleOf, ValueType(actual).Move(), expected);
|
1889
2001
|
}
|
1890
2002
|
void AboveMaximum(int64_t actual, const SValue& expected, bool exclusive) {
|
1891
|
-
AddNumberError(
|
2003
|
+
AddNumberError(exclusive ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum, ValueType(actual).Move(), expected,
|
1892
2004
|
exclusive ? &SchemaType::GetExclusiveMaximumString : 0);
|
1893
2005
|
}
|
1894
2006
|
void AboveMaximum(uint64_t actual, const SValue& expected, bool exclusive) {
|
1895
|
-
AddNumberError(
|
2007
|
+
AddNumberError(exclusive ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum, ValueType(actual).Move(), expected,
|
1896
2008
|
exclusive ? &SchemaType::GetExclusiveMaximumString : 0);
|
1897
2009
|
}
|
1898
2010
|
void AboveMaximum(double actual, const SValue& expected, bool exclusive) {
|
1899
|
-
AddNumberError(
|
2011
|
+
AddNumberError(exclusive ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum, ValueType(actual).Move(), expected,
|
1900
2012
|
exclusive ? &SchemaType::GetExclusiveMaximumString : 0);
|
1901
2013
|
}
|
1902
2014
|
void BelowMinimum(int64_t actual, const SValue& expected, bool exclusive) {
|
1903
|
-
AddNumberError(
|
2015
|
+
AddNumberError(exclusive ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum, ValueType(actual).Move(), expected,
|
1904
2016
|
exclusive ? &SchemaType::GetExclusiveMinimumString : 0);
|
1905
2017
|
}
|
1906
2018
|
void BelowMinimum(uint64_t actual, const SValue& expected, bool exclusive) {
|
1907
|
-
AddNumberError(
|
2019
|
+
AddNumberError(exclusive ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum, ValueType(actual).Move(), expected,
|
1908
2020
|
exclusive ? &SchemaType::GetExclusiveMinimumString : 0);
|
1909
2021
|
}
|
1910
2022
|
void BelowMinimum(double actual, const SValue& expected, bool exclusive) {
|
1911
|
-
AddNumberError(
|
2023
|
+
AddNumberError(exclusive ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum, ValueType(actual).Move(), expected,
|
1912
2024
|
exclusive ? &SchemaType::GetExclusiveMinimumString : 0);
|
1913
2025
|
}
|
1914
2026
|
|
1915
2027
|
void TooLong(const Ch* str, SizeType length, SizeType expected) {
|
1916
|
-
AddNumberError(
|
2028
|
+
AddNumberError(kValidateErrorMaxLength,
|
1917
2029
|
ValueType(str, length, GetStateAllocator()).Move(), SValue(expected).Move());
|
1918
2030
|
}
|
1919
2031
|
void TooShort(const Ch* str, SizeType length, SizeType expected) {
|
1920
|
-
AddNumberError(
|
2032
|
+
AddNumberError(kValidateErrorMinLength,
|
1921
2033
|
ValueType(str, length, GetStateAllocator()).Move(), SValue(expected).Move());
|
1922
2034
|
}
|
1923
2035
|
void DoesNotMatch(const Ch* str, SizeType length) {
|
1924
2036
|
currentError_.SetObject();
|
1925
2037
|
currentError_.AddMember(GetActualString(), ValueType(str, length, GetStateAllocator()).Move(), GetStateAllocator());
|
1926
|
-
AddCurrentError(
|
2038
|
+
AddCurrentError(kValidateErrorPattern);
|
1927
2039
|
}
|
1928
2040
|
|
1929
2041
|
void DisallowedItem(SizeType index) {
|
1930
2042
|
currentError_.SetObject();
|
1931
2043
|
currentError_.AddMember(GetDisallowedString(), ValueType(index).Move(), GetStateAllocator());
|
1932
|
-
AddCurrentError(
|
2044
|
+
AddCurrentError(kValidateErrorAdditionalItems, true);
|
1933
2045
|
}
|
1934
2046
|
void TooFewItems(SizeType actualCount, SizeType expectedCount) {
|
1935
|
-
AddNumberError(
|
2047
|
+
AddNumberError(kValidateErrorMinItems,
|
1936
2048
|
ValueType(actualCount).Move(), SValue(expectedCount).Move());
|
1937
2049
|
}
|
1938
2050
|
void TooManyItems(SizeType actualCount, SizeType expectedCount) {
|
1939
|
-
AddNumberError(
|
2051
|
+
AddNumberError(kValidateErrorMaxItems,
|
1940
2052
|
ValueType(actualCount).Move(), SValue(expectedCount).Move());
|
1941
2053
|
}
|
1942
2054
|
void DuplicateItems(SizeType index1, SizeType index2) {
|
@@ -1945,15 +2057,15 @@ public:
|
|
1945
2057
|
duplicates.PushBack(index2, GetStateAllocator());
|
1946
2058
|
currentError_.SetObject();
|
1947
2059
|
currentError_.AddMember(GetDuplicatesString(), duplicates, GetStateAllocator());
|
1948
|
-
AddCurrentError(
|
2060
|
+
AddCurrentError(kValidateErrorUniqueItems, true);
|
1949
2061
|
}
|
1950
2062
|
|
1951
2063
|
void TooManyProperties(SizeType actualCount, SizeType expectedCount) {
|
1952
|
-
AddNumberError(
|
2064
|
+
AddNumberError(kValidateErrorMaxProperties,
|
1953
2065
|
ValueType(actualCount).Move(), SValue(expectedCount).Move());
|
1954
2066
|
}
|
1955
2067
|
void TooFewProperties(SizeType actualCount, SizeType expectedCount) {
|
1956
|
-
AddNumberError(
|
2068
|
+
AddNumberError(kValidateErrorMinProperties,
|
1957
2069
|
ValueType(actualCount).Move(), SValue(expectedCount).Move());
|
1958
2070
|
}
|
1959
2071
|
void StartMissingProperties() {
|
@@ -1968,7 +2080,7 @@ public:
|
|
1968
2080
|
ValueType error(kObjectType);
|
1969
2081
|
error.AddMember(GetMissingString(), currentError_, GetStateAllocator());
|
1970
2082
|
currentError_ = error;
|
1971
|
-
AddCurrentError(
|
2083
|
+
AddCurrentError(kValidateErrorRequired);
|
1972
2084
|
return true;
|
1973
2085
|
}
|
1974
2086
|
void PropertyViolations(ISchemaValidator** subvalidators, SizeType count) {
|
@@ -1978,7 +2090,7 @@ public:
|
|
1978
2090
|
void DisallowedProperty(const Ch* name, SizeType length) {
|
1979
2091
|
currentError_.SetObject();
|
1980
2092
|
currentError_.AddMember(GetDisallowedString(), ValueType(name, length, GetStateAllocator()).Move(), GetStateAllocator());
|
1981
|
-
AddCurrentError(
|
2093
|
+
AddCurrentError(kValidateErrorAdditionalProperties, true);
|
1982
2094
|
}
|
1983
2095
|
|
1984
2096
|
void StartDependencyErrors() {
|
@@ -1991,9 +2103,20 @@ public:
|
|
1991
2103
|
missingDependents_.PushBack(ValueType(targetName, GetStateAllocator()).Move(), GetStateAllocator());
|
1992
2104
|
}
|
1993
2105
|
void EndMissingDependentProperties(const SValue& sourceName) {
|
1994
|
-
if (!missingDependents_.Empty())
|
1995
|
-
|
1996
|
-
|
2106
|
+
if (!missingDependents_.Empty()) {
|
2107
|
+
// Create equivalent 'required' error
|
2108
|
+
ValueType error(kObjectType);
|
2109
|
+
ValidateErrorCode code = kValidateErrorRequired;
|
2110
|
+
error.AddMember(GetMissingString(), missingDependents_.Move(), GetStateAllocator());
|
2111
|
+
AddErrorCode(error, code);
|
2112
|
+
AddErrorInstanceLocation(error, false);
|
2113
|
+
// When appending to a pointer ensure its allocator is used
|
2114
|
+
PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetInvalidSchemaPointer().GetAllocator());
|
2115
|
+
AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetInvalidSchemaPointer().GetAllocator()));
|
2116
|
+
ValueType wrapper(kObjectType);
|
2117
|
+
wrapper.AddMember(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator()).Move(), error, GetStateAllocator());
|
2118
|
+
currentError_.AddMember(ValueType(sourceName, GetStateAllocator()).Move(), wrapper, GetStateAllocator());
|
2119
|
+
}
|
1997
2120
|
}
|
1998
2121
|
void AddDependencySchemaError(const SValue& sourceName, ISchemaValidator* subvalidator) {
|
1999
2122
|
currentError_.AddMember(ValueType(sourceName, GetStateAllocator()).Move(),
|
@@ -2005,13 +2128,13 @@ public:
|
|
2005
2128
|
ValueType error(kObjectType);
|
2006
2129
|
error.AddMember(GetErrorsString(), currentError_, GetStateAllocator());
|
2007
2130
|
currentError_ = error;
|
2008
|
-
AddCurrentError(
|
2131
|
+
AddCurrentError(kValidateErrorDependencies);
|
2009
2132
|
return true;
|
2010
2133
|
}
|
2011
2134
|
|
2012
|
-
void DisallowedValue() {
|
2135
|
+
void DisallowedValue(const ValidateErrorCode code = kValidateErrorEnum) {
|
2013
2136
|
currentError_.SetObject();
|
2014
|
-
AddCurrentError(
|
2137
|
+
AddCurrentError(code);
|
2015
2138
|
}
|
2016
2139
|
void StartDisallowedType() {
|
2017
2140
|
currentError_.SetArray();
|
@@ -2024,22 +2147,24 @@ public:
|
|
2024
2147
|
error.AddMember(GetExpectedString(), currentError_, GetStateAllocator());
|
2025
2148
|
error.AddMember(GetActualString(), ValueType(actualType, GetStateAllocator()).Move(), GetStateAllocator());
|
2026
2149
|
currentError_ = error;
|
2027
|
-
AddCurrentError(
|
2150
|
+
AddCurrentError(kValidateErrorType);
|
2028
2151
|
}
|
2029
2152
|
void NotAllOf(ISchemaValidator** subvalidators, SizeType count) {
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2153
|
+
// Treat allOf like oneOf and anyOf to match https://rapidjson.org/md_doc_schema.html#allOf-anyOf-oneOf
|
2154
|
+
AddErrorArray(kValidateErrorAllOf, subvalidators, count);
|
2155
|
+
//for (SizeType i = 0; i < count; ++i) {
|
2156
|
+
// MergeError(static_cast<GenericSchemaValidator*>(subvalidators[i])->GetError());
|
2157
|
+
//}
|
2033
2158
|
}
|
2034
2159
|
void NoneOf(ISchemaValidator** subvalidators, SizeType count) {
|
2035
|
-
AddErrorArray(
|
2160
|
+
AddErrorArray(kValidateErrorAnyOf, subvalidators, count);
|
2036
2161
|
}
|
2037
|
-
void NotOneOf(ISchemaValidator** subvalidators, SizeType count) {
|
2038
|
-
AddErrorArray(
|
2162
|
+
void NotOneOf(ISchemaValidator** subvalidators, SizeType count, bool matched = false) {
|
2163
|
+
AddErrorArray(matched ? kValidateErrorOneOfMatch : kValidateErrorOneOf, subvalidators, count);
|
2039
2164
|
}
|
2040
2165
|
void Disallowed() {
|
2041
2166
|
currentError_.SetObject();
|
2042
|
-
AddCurrentError(
|
2167
|
+
AddCurrentError(kValidateErrorNot);
|
2043
2168
|
}
|
2044
2169
|
|
2045
2170
|
#define RAPIDJSON_STRING_(name, ...) \
|
@@ -2056,6 +2181,8 @@ public:
|
|
2056
2181
|
RAPIDJSON_STRING_(Disallowed, 'd', 'i', 's', 'a', 'l', 'l', 'o', 'w', 'e', 'd')
|
2057
2182
|
RAPIDJSON_STRING_(Missing, 'm', 'i', 's', 's', 'i', 'n', 'g')
|
2058
2183
|
RAPIDJSON_STRING_(Errors, 'e', 'r', 'r', 'o', 'r', 's')
|
2184
|
+
RAPIDJSON_STRING_(ErrorCode, 'e', 'r', 'r', 'o', 'r', 'C', 'o', 'd', 'e')
|
2185
|
+
RAPIDJSON_STRING_(ErrorMessage, 'e', 'r', 'r', 'o', 'r', 'M', 'e', 's', 's', 'a', 'g', 'e')
|
2059
2186
|
RAPIDJSON_STRING_(Duplicates, 'd', 'u', 'p', 'l', 'i', 'c', 'a', 't', 'e', 's')
|
2060
2187
|
|
2061
2188
|
#undef RAPIDJSON_STRING_
|
@@ -2073,7 +2200,7 @@ RAPIDJSON_MULTILINEMACRO_END
|
|
2073
2200
|
|
2074
2201
|
#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)\
|
2075
2202
|
if (!valid_) return false; \
|
2076
|
-
if (!BeginValue() || !CurrentSchema().method arg1) {\
|
2203
|
+
if ((!BeginValue() && !GetContinueOnErrors()) || (!CurrentSchema().method arg1 && !GetContinueOnErrors())) {\
|
2077
2204
|
RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_();\
|
2078
2205
|
return valid_ = false;\
|
2079
2206
|
}
|
@@ -2091,7 +2218,8 @@ RAPIDJSON_MULTILINEMACRO_END
|
|
2091
2218
|
}
|
2092
2219
|
|
2093
2220
|
#define RAPIDJSON_SCHEMA_HANDLE_END_(method, arg2)\
|
2094
|
-
|
2221
|
+
valid_ = (EndValue() || GetContinueOnErrors()) && (!outputHandler_ || outputHandler_->method arg2);\
|
2222
|
+
return valid_;
|
2095
2223
|
|
2096
2224
|
#define RAPIDJSON_SCHEMA_HANDLE_VALUE_(method, arg1, arg2) \
|
2097
2225
|
RAPIDJSON_SCHEMA_HANDLE_BEGIN_ (method, arg1);\
|
@@ -2119,15 +2247,15 @@ RAPIDJSON_MULTILINEMACRO_END
|
|
2119
2247
|
bool Key(const Ch* str, SizeType len, bool copy) {
|
2120
2248
|
if (!valid_) return false;
|
2121
2249
|
AppendToken(str, len);
|
2122
|
-
if (!CurrentSchema().Key(CurrentContext(), str, len, copy)) return valid_ = false;
|
2250
|
+
if (!CurrentSchema().Key(CurrentContext(), str, len, copy) && !GetContinueOnErrors()) return valid_ = false;
|
2123
2251
|
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(Key, (str, len, copy));
|
2124
2252
|
return valid_ = !outputHandler_ || outputHandler_->Key(str, len, copy);
|
2125
2253
|
}
|
2126
2254
|
|
2127
|
-
bool EndObject(SizeType memberCount) {
|
2255
|
+
bool EndObject(SizeType memberCount) {
|
2128
2256
|
if (!valid_) return false;
|
2129
2257
|
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndObject, (memberCount));
|
2130
|
-
if (!CurrentSchema().EndObject(CurrentContext(), memberCount)) return valid_ = false;
|
2258
|
+
if (!CurrentSchema().EndObject(CurrentContext(), memberCount) && !GetContinueOnErrors()) return valid_ = false;
|
2131
2259
|
RAPIDJSON_SCHEMA_HANDLE_END_(EndObject, (memberCount));
|
2132
2260
|
}
|
2133
2261
|
|
@@ -2140,7 +2268,7 @@ RAPIDJSON_MULTILINEMACRO_END
|
|
2140
2268
|
bool EndArray(SizeType elementCount) {
|
2141
2269
|
if (!valid_) return false;
|
2142
2270
|
RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndArray, (elementCount));
|
2143
|
-
if (!CurrentSchema().EndArray(CurrentContext(), elementCount)) return valid_ = false;
|
2271
|
+
if (!CurrentSchema().EndArray(CurrentContext(), elementCount) && !GetContinueOnErrors()) return valid_ = false;
|
2144
2272
|
RAPIDJSON_SCHEMA_HANDLE_END_(EndArray, (elementCount));
|
2145
2273
|
}
|
2146
2274
|
|
@@ -2150,12 +2278,14 @@ RAPIDJSON_MULTILINEMACRO_END
|
|
2150
2278
|
#undef RAPIDJSON_SCHEMA_HANDLE_VALUE_
|
2151
2279
|
|
2152
2280
|
// Implementation of ISchemaStateFactory<SchemaType>
|
2153
|
-
virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root) {
|
2154
|
-
|
2281
|
+
virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root, const bool inheritContinueOnErrors) {
|
2282
|
+
ISchemaValidator* sv = new (GetStateAllocator().Malloc(sizeof(GenericSchemaValidator))) GenericSchemaValidator(*schemaDocument_, root, documentStack_.template Bottom<char>(), documentStack_.GetSize(),
|
2155
2283
|
#if RAPIDJSON_SCHEMA_VERBOSE
|
2156
2284
|
depth_ + 1,
|
2157
2285
|
#endif
|
2158
2286
|
&GetStateAllocator());
|
2287
|
+
sv->SetValidateFlags(inheritContinueOnErrors ? GetValidateFlags() : GetValidateFlags() & ~(unsigned)kValidateContinueOnErrorFlag);
|
2288
|
+
return sv;
|
2159
2289
|
}
|
2160
2290
|
|
2161
2291
|
virtual void DestroySchemaValidator(ISchemaValidator* validator) {
|
@@ -2212,7 +2342,8 @@ private:
|
|
2212
2342
|
error_(kObjectType),
|
2213
2343
|
currentError_(),
|
2214
2344
|
missingDependents_(),
|
2215
|
-
valid_(true)
|
2345
|
+
valid_(true),
|
2346
|
+
flags_(kValidateDefaultFlags)
|
2216
2347
|
#if RAPIDJSON_SCHEMA_VERBOSE
|
2217
2348
|
, depth_(depth)
|
2218
2349
|
#endif
|
@@ -2227,6 +2358,10 @@ private:
|
|
2227
2358
|
return *stateAllocator_;
|
2228
2359
|
}
|
2229
2360
|
|
2361
|
+
bool GetContinueOnErrors() const {
|
2362
|
+
return flags_ & kValidateContinueOnErrorFlag;
|
2363
|
+
}
|
2364
|
+
|
2230
2365
|
bool BeginValue() {
|
2231
2366
|
if (schemaStack_.Empty())
|
2232
2367
|
PushSchema(root_);
|
@@ -2234,7 +2369,7 @@ private:
|
|
2234
2369
|
if (CurrentContext().inArray)
|
2235
2370
|
internal::TokenHelper<internal::Stack<StateAllocator>, Ch>::AppendIndexToken(documentStack_, CurrentContext().arrayElementIndex);
|
2236
2371
|
|
2237
|
-
if (!CurrentSchema().BeginValue(CurrentContext()))
|
2372
|
+
if (!CurrentSchema().BeginValue(CurrentContext()) && !GetContinueOnErrors())
|
2238
2373
|
return false;
|
2239
2374
|
|
2240
2375
|
SizeType count = CurrentContext().patternPropertiesSchemaCount;
|
@@ -2250,7 +2385,7 @@ private:
|
|
2250
2385
|
SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount;
|
2251
2386
|
va = static_cast<ISchemaValidator**>(MallocState(sizeof(ISchemaValidator*) * count));
|
2252
2387
|
for (SizeType i = 0; i < count; i++)
|
2253
|
-
va[validatorCount++] = CreateSchemaValidator(*sa[i]);
|
2388
|
+
va[validatorCount++] = CreateSchemaValidator(*sa[i], true); // Inherit continueOnError
|
2254
2389
|
}
|
2255
2390
|
|
2256
2391
|
CurrentContext().arrayUniqueness = valueUniqueness;
|
@@ -2259,7 +2394,7 @@ private:
|
|
2259
2394
|
}
|
2260
2395
|
|
2261
2396
|
bool EndValue() {
|
2262
|
-
if (!CurrentSchema().EndValue(CurrentContext()))
|
2397
|
+
if (!CurrentSchema().EndValue(CurrentContext()) && !GetContinueOnErrors())
|
2263
2398
|
return false;
|
2264
2399
|
|
2265
2400
|
#if RAPIDJSON_SCHEMA_VERBOSE
|
@@ -2270,21 +2405,27 @@ private:
|
|
2270
2405
|
documentStack_.template Pop<Ch>(1);
|
2271
2406
|
internal::PrintValidatorPointers(depth_, sb.GetString(), documentStack_.template Bottom<Ch>());
|
2272
2407
|
#endif
|
2273
|
-
|
2274
|
-
uint64_t h = CurrentContext().arrayUniqueness ? static_cast<HasherType*>(
|
2408
|
+
void* hasher = CurrentContext().hasher;
|
2409
|
+
uint64_t h = hasher && CurrentContext().arrayUniqueness ? static_cast<HasherType*>(hasher)->GetHashCode() : 0;
|
2275
2410
|
|
2276
2411
|
PopSchema();
|
2277
2412
|
|
2278
2413
|
if (!schemaStack_.Empty()) {
|
2279
2414
|
Context& context = CurrentContext();
|
2280
|
-
if
|
2415
|
+
// Only check uniqueness if there is a hasher
|
2416
|
+
if (hasher && context.valueUniqueness) {
|
2281
2417
|
HashCodeArray* a = static_cast<HashCodeArray*>(context.arrayElementHashCodes);
|
2282
2418
|
if (!a)
|
2283
2419
|
CurrentContext().arrayElementHashCodes = a = new (GetStateAllocator().Malloc(sizeof(HashCodeArray))) HashCodeArray(kArrayType);
|
2284
2420
|
for (typename HashCodeArray::ConstValueIterator itr = a->Begin(); itr != a->End(); ++itr)
|
2285
2421
|
if (itr->GetUint64() == h) {
|
2286
2422
|
DuplicateItems(static_cast<SizeType>(itr - a->Begin()), a->Size());
|
2287
|
-
|
2423
|
+
// Cleanup before returning if continuing
|
2424
|
+
if (GetContinueOnErrors()) {
|
2425
|
+
a->PushBack(h, GetStateAllocator());
|
2426
|
+
while (!documentStack_.Empty() && *documentStack_.template Pop<Ch>(1) != '/');
|
2427
|
+
}
|
2428
|
+
RAPIDJSON_INVALID_KEYWORD_RETURN(kValidateErrorUniqueItems);
|
2288
2429
|
}
|
2289
2430
|
a->PushBack(h, GetStateAllocator());
|
2290
2431
|
}
|
@@ -2325,25 +2466,32 @@ private:
|
|
2325
2466
|
c->~Context();
|
2326
2467
|
}
|
2327
2468
|
|
2328
|
-
void
|
2469
|
+
void AddErrorInstanceLocation(ValueType& result, bool parent) {
|
2329
2470
|
GenericStringBuffer<EncodingType> sb;
|
2330
2471
|
PointerType instancePointer = GetInvalidDocumentPointer();
|
2331
2472
|
((parent && instancePointer.GetTokenCount() > 0)
|
2332
|
-
|
2333
|
-
|
2473
|
+
? PointerType(instancePointer.GetTokens(), instancePointer.GetTokenCount() - 1)
|
2474
|
+
: instancePointer).StringifyUriFragment(sb);
|
2334
2475
|
ValueType instanceRef(sb.GetString(), static_cast<SizeType>(sb.GetSize() / sizeof(Ch)),
|
2335
|
-
|
2476
|
+
GetStateAllocator());
|
2336
2477
|
result.AddMember(GetInstanceRefString(), instanceRef, GetStateAllocator());
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2478
|
+
}
|
2479
|
+
|
2480
|
+
void AddErrorSchemaLocation(ValueType& result, PointerType schema = PointerType()) {
|
2481
|
+
GenericStringBuffer<EncodingType> sb;
|
2482
|
+
SizeType len = CurrentSchema().GetURI().GetStringLength();
|
2483
|
+
if (len) memcpy(sb.Push(len), CurrentSchema().GetURI().GetString(), len * sizeof(Ch));
|
2484
|
+
if (schema.GetTokenCount()) schema.StringifyUriFragment(sb);
|
2485
|
+
else GetInvalidSchemaPointer().StringifyUriFragment(sb);
|
2342
2486
|
ValueType schemaRef(sb.GetString(), static_cast<SizeType>(sb.GetSize() / sizeof(Ch)),
|
2343
2487
|
GetStateAllocator());
|
2344
2488
|
result.AddMember(GetSchemaRefString(), schemaRef, GetStateAllocator());
|
2345
2489
|
}
|
2346
2490
|
|
2491
|
+
void AddErrorCode(ValueType& result, const ValidateErrorCode code) {
|
2492
|
+
result.AddMember(GetErrorCodeString(), code, GetStateAllocator());
|
2493
|
+
}
|
2494
|
+
|
2347
2495
|
void AddError(ValueType& keyword, ValueType& error) {
|
2348
2496
|
typename ValueType::MemberIterator member = error_.FindMember(keyword);
|
2349
2497
|
if (member == error_.MemberEnd())
|
@@ -2358,9 +2506,11 @@ private:
|
|
2358
2506
|
}
|
2359
2507
|
}
|
2360
2508
|
|
2361
|
-
void AddCurrentError(const
|
2362
|
-
|
2363
|
-
|
2509
|
+
void AddCurrentError(const ValidateErrorCode code, bool parent = false) {
|
2510
|
+
AddErrorCode(currentError_, code);
|
2511
|
+
AddErrorInstanceLocation(currentError_, parent);
|
2512
|
+
AddErrorSchemaLocation(currentError_);
|
2513
|
+
AddError(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator(), false).Move(), currentError_);
|
2364
2514
|
}
|
2365
2515
|
|
2366
2516
|
void MergeError(ValueType& other) {
|
@@ -2369,24 +2519,24 @@ private:
|
|
2369
2519
|
}
|
2370
2520
|
}
|
2371
2521
|
|
2372
|
-
void AddNumberError(const
|
2522
|
+
void AddNumberError(const ValidateErrorCode code, ValueType& actual, const SValue& expected,
|
2373
2523
|
const typename SchemaType::ValueType& (*exclusive)() = 0) {
|
2374
2524
|
currentError_.SetObject();
|
2375
2525
|
currentError_.AddMember(GetActualString(), actual, GetStateAllocator());
|
2376
2526
|
currentError_.AddMember(GetExpectedString(), ValueType(expected, GetStateAllocator()).Move(), GetStateAllocator());
|
2377
2527
|
if (exclusive)
|
2378
2528
|
currentError_.AddMember(ValueType(exclusive(), GetStateAllocator()).Move(), true, GetStateAllocator());
|
2379
|
-
AddCurrentError(
|
2529
|
+
AddCurrentError(code);
|
2380
2530
|
}
|
2381
2531
|
|
2382
|
-
void AddErrorArray(const
|
2532
|
+
void AddErrorArray(const ValidateErrorCode code,
|
2383
2533
|
ISchemaValidator** subvalidators, SizeType count) {
|
2384
2534
|
ValueType errors(kArrayType);
|
2385
2535
|
for (SizeType i = 0; i < count; ++i)
|
2386
2536
|
errors.PushBack(static_cast<GenericSchemaValidator*>(subvalidators[i])->GetError(), GetStateAllocator());
|
2387
2537
|
currentError_.SetObject();
|
2388
2538
|
currentError_.AddMember(GetErrorsString(), errors, GetStateAllocator());
|
2389
|
-
AddCurrentError(
|
2539
|
+
AddCurrentError(code);
|
2390
2540
|
}
|
2391
2541
|
|
2392
2542
|
const SchemaType& CurrentSchema() const { return *schemaStack_.template Top<Context>()->schema; }
|
@@ -2406,6 +2556,7 @@ private:
|
|
2406
2556
|
ValueType currentError_;
|
2407
2557
|
ValueType missingDependents_;
|
2408
2558
|
bool valid_;
|
2559
|
+
unsigned flags_;
|
2409
2560
|
#if RAPIDJSON_SCHEMA_VERBOSE
|
2410
2561
|
unsigned depth_;
|
2411
2562
|
#endif
|
@@ -2443,7 +2594,7 @@ public:
|
|
2443
2594
|
\param is Input stream.
|
2444
2595
|
\param sd Schema document.
|
2445
2596
|
*/
|
2446
|
-
SchemaValidatingReader(InputStream& is, const SchemaDocumentType& sd) : is_(is), sd_(sd), invalidSchemaKeyword_(), error_(kObjectType), isValid_(true) {}
|
2597
|
+
SchemaValidatingReader(InputStream& is, const SchemaDocumentType& sd) : is_(is), sd_(sd), invalidSchemaKeyword_(), invalidSchemaCode_(kValidateErrorNone), error_(kObjectType), isValid_(true) {}
|
2447
2598
|
|
2448
2599
|
template <typename Handler>
|
2449
2600
|
bool operator()(Handler& handler) {
|
@@ -2461,6 +2612,7 @@ public:
|
|
2461
2612
|
else {
|
2462
2613
|
invalidSchemaPointer_ = validator.GetInvalidSchemaPointer();
|
2463
2614
|
invalidSchemaKeyword_ = validator.GetInvalidSchemaKeyword();
|
2615
|
+
invalidSchemaCode_ = validator.GetInvalidSchemaCode();
|
2464
2616
|
invalidDocumentPointer_ = validator.GetInvalidDocumentPointer();
|
2465
2617
|
error_.CopyFrom(validator.GetError(), allocator_);
|
2466
2618
|
}
|
@@ -2474,6 +2626,7 @@ public:
|
|
2474
2626
|
const Ch* GetInvalidSchemaKeyword() const { return invalidSchemaKeyword_; }
|
2475
2627
|
const PointerType& GetInvalidDocumentPointer() const { return invalidDocumentPointer_; }
|
2476
2628
|
const ValueType& GetError() const { return error_; }
|
2629
|
+
ValidateErrorCode GetInvalidSchemaCode() const { return invalidSchemaCode_; }
|
2477
2630
|
|
2478
2631
|
private:
|
2479
2632
|
InputStream& is_;
|
@@ -2483,6 +2636,7 @@ private:
|
|
2483
2636
|
PointerType invalidSchemaPointer_;
|
2484
2637
|
const Ch* invalidSchemaKeyword_;
|
2485
2638
|
PointerType invalidDocumentPointer_;
|
2639
|
+
ValidateErrorCode invalidSchemaCode_;
|
2486
2640
|
StackAllocator allocator_;
|
2487
2641
|
ValueType error_;
|
2488
2642
|
bool isValid_;
|