Skip to content

Commit

Permalink
Upgrade draft3 divisibleBy to multipleOf
Browse files Browse the repository at this point in the history
See: #83
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti committed Nov 5, 2022
1 parent 1d057eb commit 868399b
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rules/jsonschema-draft3-to-draft4.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@
"transform": {
"$eval": "omit(schema, 'type')"
}
},
{
"vocabulary": "core",
"condition": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/sourcemeta/alterschema/rules/jsonschema-draft3-to-draft4/divisible-by",
"type": "object",
"required": [ "divisibleBy" ],
"properties": {
"divisibleBy": {
"type": "number"
}
}
},
"transform": {
"$merge": [
{ "$eval": "omit(schema, 'divisibleBy')" },
{
"multipleOf": {
"$eval": "schema.divisibleBy"
}
}
]
}
}
]
}
13 changes: 13 additions & 0 deletions test/rules/jsonschema-draft3-to-2019-09.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft3 divisibleBy",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "integer",
"divisibleBy": 5
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "integer",
"multipleOf": 5
}
}
]
13 changes: 13 additions & 0 deletions test/rules/jsonschema-draft3-to-2020-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft3 divisibleBy",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "integer",
"divisibleBy": 5
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "integer",
"multipleOf": 5
}
}
]
13 changes: 13 additions & 0 deletions test/rules/jsonschema-draft3-to-draft4.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@
"expected": {
"$schema": "http://json-schema.org/draft-04/schema#"
}
},
{
"name": "draft3 divisibleBy",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "integer",
"divisibleBy": 5
},
"expected": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "integer",
"multipleOf": 5
}
}
]
13 changes: 13 additions & 0 deletions test/rules/jsonschema-draft3-to-draft6.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#"
}
},
{
"name": "draft3 divisibleBy",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "integer",
"divisibleBy": 5
},
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#",
"type": "integer",
"multipleOf": 5
}
}
]
13 changes: 13 additions & 0 deletions test/rules/jsonschema-draft3-to-draft7.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,18 @@
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft3 divisibleBy",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "integer",
"divisibleBy": 5
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "integer",
"multipleOf": 5
}
}
]

0 comments on commit 868399b

Please sign in to comment.