# JSON schema validation not working

**URL:** <https://forum.liquibase.org/t/json-schema-validation-not-working/6283>\
**Category:** General Discussion\
**Created:** [December 21, 2021, 2:42pm UTC](https://forum.liquibase.org/t/json-schema-validation-not-working/6283 "2021-12-21T14:42:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev13](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dev13](https://forum.liquibase.org/u/dev13)\
**Post date:** [December 21, 2021, 2:42pm UTC](https://forum.liquibase.org/t/json-schema-validation-not-working/6283/1 "2021-12-21T14:42:19Z")

</div>

liquibase-mongodb → 4.5.0

rule validations are not created for the collection.

example of a databaseChangeLog file:

```auto
{
"databaseChangeLog": [
{
"changeSet": {
"id": "1",
"author": "author",
"preConditions": [
{
"onFail": "WARN"
},
{
"documentExists": {
"collectionName": "student"
}
}
],
"comment": "Create collection",
"changes": [
{
"createCollection": {
"collectionName": "student",
"validator": {
"$jsonSchema": {
"bsonType": "object"
"properties": {
"studentId": {
"bsonType": "string",
"maxLength": 8,
"description": "student id"
},
"description": {
"bsonType": "string",
"maxLength": 50,
"description": "description"
}
}
}
},
"validationAction": "error",
"validationLevel": "strict"
}
}
]
}
}
]
}

```

---

<div class="post-metadata">

**Author:** ![tabbyfoo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.liquibase.org/tabbyfoo/32/748_2.png) [@tabbyfoo](https://forum.liquibase.org/u/tabbyfoo)\
**Post date:** [April 13, 2022, 7:44pm UTC](https://forum.liquibase.org/t/json-schema-validation-not-working/6283/2 "2022-04-13T19:44:55Z")

</div>

Hello, @dev13 and welcome to the Liquibase community!

I’ve been able to gather some info from our internal team to help you with this issue, but first, I wanted to mention that we are currently at Liquibase version 4.9.1, and this post is from 4.5. if you’ve updated your version to 4.9.1, are you still having this issue?

I saw that you also posted this on the liquibase-mongodb github here: [JSON schema validation not working · Issue #207 · liquibase/liquibase-mongodb · GitHub](https://github.com/liquibase/liquibase-mongodb/issues/207)

There are a couple resources you may find helpful in formatting your schema validation using JSON/MongoDB/Liquibase. You’ll need to wrap your JSON validation code in order for Liquibase to process it, as we currently only support XML in MongoDB.

- [Set Validation Rules for Your Schema](https://www.mongodb.com/docs/compass/current/validation/) | MongoDB Docs
- [Using Liquibase with MongoDB | Liquibase Docs](https://docs.liquibase.com/install/tutorials/mongodb.html#:~:text=Add%20a%20changeset%20to%20the%20changelog%20%E2%80%93%20changesets%20are%20uniquely%20identified%20by%20author%20and%20id%20attributes.%20Liquibase%20attempts%20to%20execute%20each%20changeset%20in%20a%20transaction%20that%20is%20committed%20at%20the%20end.%20In%20the%20dbchangelog.xml%20file%2C%20add%20a%20new%20collection%20myCollection%20changesets%20as%20follows%3A) - Tutorial step 6
- [Using Liquibase with MongoDB | Liquibase Docs](https://docs.liquibase.com/install/tutorials/mongodb.html#:~:text=runCommand%20provides%20a%20helper%20to%20run%20specified%20database%20commands.%20This%20is%20the%20preferred%20method%20to%20issue%20database%20commands%20as%20it%20provides%20a%20consistent%20interface%20between%20the%20shell%20and%20drivers) - MongoDB Commands Examples: [runCommand](https://docs.mongodb.com/manual/reference/method/db.runCommand/#db-runcommand)

If you have any further questions, please don’t hesitate to ask!

Kindly,  
Tabby
