RXNT / react-jsonschema-form-conditionals

react-jsonschema-form-conditionals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unusable if Field Keys Contain "."

lucasgauk opened this issue · comments

Given a valid schema like the following:

{
  "type": "object",
  "required": [
    "first.name",
  ],
  "properties": {
    "first.name": {
      "type": "string",
      "title": "First name",
      "default": "Chuck"
    }
  }
}

There would be no way create a rule to target the first name field with this library.

Looks like using "." as a separator only is baked pretty deep here. I think a reasonable solution would be a greedy check of properties in the schema. If I pass a field with key "foo.bar" the first thing should not be to check a separator like var separator = "foo.bar".indexOf("."); it should be to see if schema.properties["foo.bar"] exists.

Expected is that I can create a rule like the following:

[{
	"conditions": {
             "first.name": { "is": "foo" }
	},
	"event": {
		"type": "remove",
		"params": {
			"field": "bar"
		}
	}
}]

Actual is an error:

"first not defined in properties"