json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Does it support Property dependencies? #951

Closed hamzahamidi closed 3 years ago

hamzahamidi commented 6 years ago

Expected behavior

I read in your documentation that this library support Json schema v4. Does that mean it supports Property dependencies? If a member's value of the dependencies keyword is either a string or an array of strings, then this is a property dependency. Example:

{
    "dependencies": {
        "a": "b",
        "c": [ "d", "e" ]
    }
}

In the example schema above:

I know I can achieve the same thing using the condition attribute in scope.form. But this doesn't comply with the Json schema v4.

Can someone please confirm that my expected behavior can't be achieved using this library? Thank you

Anthropic commented 6 years ago

You could implement dependency validation within an add-on fairly easily, as you can see with this inline options directive, you can apply an object level validation to do anything you like quite easily. In that case it was for anyOf, but there would not be much effort required to test dependencies to the level that tv4 was supporting them.

The current way to do it would be via the ui schema as you already noted. There's a lot of reasons it was done this way I suspect, but I will make it work out of the box once the validator has been updated in the new version I am working on. I can't give any accurate time estimates on it at this stage though sorry.

Anthropic commented 6 years ago

Note on your example, "a": "b" would be invalid, even a single item has to be within an array "a": ["b"] when creating a property dependency, otherwise a complete JSON Schema object is required for a schema dependency.