Browse Source

change pattern to ignore conditional_route_to

pull/76/head
magicmilo 3 years ago
parent
commit
c67fccdcd0
  1. 1
      app/helpers/json_schema_validation.rb
  2. 6
      config/forms/schema/generic.json
  3. 4
      spec/fixtures/forms/test_validator.json

1
app/helpers/json_schema_validation.rb

@ -14,7 +14,6 @@ end
begin begin
path = "config/forms/schema/generic.json" path = "config/forms/schema/generic.json"
# path = "config/forms/schema/2021_2022.json"
file = File.open(path) file = File.open(path)
schema = JSON.parse(file.read) schema = JSON.parse(file.read)

6
config/forms/schema/generic.json

@ -44,7 +44,7 @@
"pages": { "pages": {
"type": "object", "type": "object",
"patternProperties": { "patternProperties": {
"[a-z_]+": { "^(?!(conditional_route_to))[a-z_]+$": {
"description": "Page Name", "description": "Page Name",
"type": "object", "type": "object",
"required": ["header", "questions"], "required": ["header", "questions"],
@ -88,6 +88,10 @@
"check_answer_label": { "check_answer_label": {
"description": "", "description": "",
"type": "string" "type": "string"
},
"conditional_for": {
"description": "",
"type": "object"
} }
}, },
"minProperties": 1 "minProperties": 1

4
spec/fixtures/forms/test_validator.json vendored

@ -11,6 +11,7 @@
"ShouldThrowError": "Shouldn't be here but what you gonna do?", "ShouldThrowError": "Shouldn't be here but what you gonna do?",
"pages": { "pages": {
"tenant_code": { "tenant_code": {
"ShouldThrowError": "Shouldn't be here but what you gonna do?",
"questions": { "questions": {
"tenant_code": { "tenant_code": {
"check_answer_label": "Tenant code", "check_answer_label": "Tenant code",
@ -19,7 +20,8 @@
} }
}, },
"conditional_route_to": {"test": "Yes"} "conditional_route_to": {"test": "Yes"}
} },
"conditional_route_to": {"test": "Yes"}
}, },
"person_1_age": { "person_1_age": {
"header": "", "header": "",

Loading…
Cancel
Save