Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. from jsonschema import validate
  2.  
  3. schema = {
  4. "type": "object",
  5. "properties": {
  6. "rabbitmq": {
  7. "type": "object",
  8. "properties": {
  9. "host": {"type": "string"},
  10. "port": {"type": "number"},
  11. "root": {"type": "string"},
  12. "login": {"type": "string"},
  13. "password": {"type": "string"},
  14. "exchange": {"type": "string"}
  15. },
  16. "required": [
  17. "host",
  18. "port",
  19. "root",
  20. "login",
  21. "password",
  22. "exchange"
  23. ]
  24. },
  25. "sftp": {
  26. "type": "object",
  27. "properties": {
  28. "host": {"type": "string"},
  29. "port": {"type": "number"},
  30. "login": {"type": "string"},
  31. "password": {"type": "string"},
  32. "cdr_dir": {"type": "string"},
  33. "remove_after_download": {"type": "string"}
  34. },
  35. "required": [
  36. "host",
  37. "port",
  38. "login",
  39. "password",
  40. "cdr_dir",
  41. "remove_after_download"
  42. ]
  43. }
  44. },
  45. "required": [
  46. "rabbitmq",
  47. "sftp"
  48. ]
  49. }
  50.  
  51. obj = {
  52. "cassandra": {
  53. "cluster": [
  54. "192.168.99.100"
  55. ],
  56. "port": 9042,
  57. "keyspace": "cdr",
  58. "batch_size": 50
  59. },
  60. "redis": {
  61. "host": "192.168.99.100",
  62. "port": 6379,
  63. "password": "",
  64. "db": 0
  65. },
  66. "delimiter": ";"
  67. }
  68.  
  69. print validate(schema, obj)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement