e0ipso / e0ipso/schema-forms-php
Loosen validation to fix error with empty objects
- Dominant language
- PHP
- Stars
- 11
- Forks
- 5
- Avg merge
- 2h 22m
- Merged PRs (30d)
- 6
Description
When using this library with the Drupal sdc_display module, it chokes on YAML structures like:
```yaml
props:
type: object
properties: {}
```
where it's not able to recognise the value of `properties` as valid. This is for two reasons:
1. The value gets deserialised as an empty array, which fails strict validation
2. Even if validation with type cast is enabled, it still fails because `(bool) $data->properties` is false (see `JsonFormValidator`, line 27)
### Steps to reproduce
See [issue](https://www.drupal.org/project/sdc_display/issues/3452406) for Single Directory Components: Display.
#### Package Versions
- [Drupal Core](https://www.drupal.org/project/drupal) 10.2.6
- [Single Directory Components: Display](https://www.drupal.org/project/sdc_display) 1.0.0-beta5
- e0ipso/schema-forms 2.5.1
- justinrainbow/json-schema 5.2.13
### Proposed resolution
1. Use `Constraint::CHECK_MODE_TYPE_CAST` in `FormGeneratorDrupal`, line 52.
2. Remove `(bool) $data->properties` from `JsonFormValidator`, line 27.
I'm well aware that this might not be the correct solution and might have implications I can't see right now. Please advise.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.