Validate JSON schema array - using JS

Asked

Viewed 58 times

0

Guys, I’m trying to perform unit tests with this JSON schema:

"Transactions":{
                "$id": "http://example.com/example.json/items",
                "type": "object",
                "additionalProperties": false,
                "properties": {                    
                    "UUU" : {
                        "description": "Valor UUU",
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 1,
                        "required": true,
                        "items":[
                            {
                            "quantity": {
                                "$id": "http://example.com/example.json/items",
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                    "ValUU": {
                                        "description": "Valor em UU",
                                        "$id": "http://example.com/example.json/items/properties/paragraphs/properties/impact",
                                        "type": "number",
                                        "title": "Valor UU",
                                        "minimum": 0,
                                        "maximum": 999999999999,
                                        "required": true
                                        },
                                    "ValU": {
                                        "description": "Valor U",
                                        "$id": "http://example.com/example.json/items/properties/paragraphs/properties/impact",
                                        "type": "number",
                                        "title": "Valor U",
                                        "minimum": 0,
                                        "maximum": 99999999999,
                                        "required": true
                                        }
                                    }
                                },

UUU is an array that is receiving the "Quantity" item, and this item has two objects inside it, I need to know a Javascript query to validate these objects within "Quantity". I am only able to communicate with the UUU array and say that it has an item.

  • tried to go the full way? type Transactions.UU.items

  • I tried yes, it is as if he did not talk with the objects of the "Quantity"

  • what I saw here would be then Transactions.properties.UUU.items , if not, try debugging a console.log(Transactions.properties) to see if it recognizes from the beginning

  • blz, vlw brother:)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.