networknt / json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Apache License 2.0
822 stars 323 forks source link

How to use to validate real data for Draft-07 #300

Closed pjain287074 closed 4 years ago

pjain287074 commented 4 years ago

Hi I am new to maven. Can you please help to understand how can i use this project to validate my JSON. I Want maven to fail if any parameter of my JSON is not as per the Defined JSON schema(or DraftV7)

stevehu commented 4 years ago

You can use any build tool like Maven or Gradle. Choose whichever you like.

pjain287074 commented 4 years ago

Do i need any plugins to use this in maven pom.... Does it validate Draftv7 schema?

On Tue, 9 Jun, 2020, 7:36 PM Steve Hu, notifications@github.com wrote:

You can use any build tool like Maven or Gradle. Choose whichever you like.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networknt/json-schema-validator/issues/300#issuecomment-641320874, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK5BRJ7U6NT5EZNAZHT7MB3RVY6X5ANCNFSM4NZK2IMQ .

stevehu commented 4 years ago

If you are preferring javac, then you don't even need Maven. Yes. it validates draftv7 schema.

pjain287074 commented 4 years ago

Happy to hear this but i have a mvn based project. Could you please please help how can i integrate this with my existing project?

As of now i am using json schema validator plugin in my maven project which does not support Draftv7. Refer below refrence project

https://github.com/groupon/json-schema-validator/blob/master/README.md

Its validating schema based on draftv4.but not validating if-then-else which is added in Draftv7

Although i tried and added all dependancies which are specified in your repo in pom.xml of my maven project.But some how it doesn't worked for me. It did not validated if-then-else that i have defined in json schema or may be i have done something wrong.

On Tue, 9 Jun, 2020, 9:00 PM Steve Hu, notifications@github.com wrote:

If you are preferring javac, then you don't even need Maven. Yes. it validates draftv7 schema.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/networknt/json-schema-validator/issues/300#issuecomment-641380186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK5BRJZKQT6YYGACFVZS34DRVZIRPANCNFSM4NZK2IMQ .

stevehu commented 4 years ago

The project is just a library and like other dependencies, you need to add it to the pom.xml file first. Then you need to add the code to validate. Take a look at the test cases and you can find the examples on how to use it.