Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. from jsonschema import validate
  2.  
  3. schema_version = {
  4.     "$schema": "http://json-schema.org/schema#",
  5.     "type": "object",
  6.     "properties": {
  7.         "version": {
  8.             "type": "string",
  9.             "pattern": "^[0-9]{0,3}.[0-9]{0,3}.[0-9]{0,3}$"
  10.         },
  11.         "url": {
  12.             "type": "string",
  13.             "format": "uri"
  14.         },
  15.         "mandatory": {
  16.             "type": "boolean"
  17.         }
  18.     },
  19.     "required": ["version", "url"],
  20.     "additionalProperties": False
  21. }
  22.  
  23. schema_versions = {
  24.     "$schema": "http://json-schema.org/schema#",
  25.     "type": "object",
  26.     "properties": {
  27.         "platforms": {
  28.             "type": "object",
  29.             "patternProperties": {
  30.                 "^ios|android$": {
  31.                     "type": "array",
  32.                     "items": {
  33.                         "$ref": "version.json"
  34.                     },
  35.                     "minItems": 1,
  36.                     "uniqueItems": True
  37.                 }
  38.             },
  39.             "additionalProperties": False
  40.         }
  41.     },
  42.     "required": ["platforms"],
  43.     "additionalProperties": False
  44. }
  45.  
  46. versions = {
  47.     "platforms": {
  48.         "ios": [
  49.             {
  50.                 "version": "0.9.26",
  51.                 "mandatory": False,
  52.                 "url": "https://www.example.com/"
  53.             },
  54.             {
  55.                 "version": "0.9.27",
  56.                 "mandatory": True,
  57.                 "url": "https://www.example.com"
  58.             }
  59.         ]
  60.     }
  61. }
  62.  
  63. validate(version, schema_versions)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement