JSON schema validation not working

liquibase-mongodb → 4.5.0

rule validations are not created for the collection.

example of a databaseChangeLog file:

{
"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"
}
}
]
}
}
]
}

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

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.

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

Kindly,
Tabby