-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional flexibility for imperativeConfiguration #56
Comments
Trying to get my head around this and the validator code that would allow it. Am wondering if it could be handled using specific Having said all that, if it's desirable to keep the various definitions of what is valid in the data-models repo, perhaps some sort of DSL could be extracted to specify these sorts of validations rules in JSON that could then be run by generic But maybe I'm overthinking it. |
Sorry @henryaddison have just seen this! So the modelling approach taken in the specification means that defining a more specific type only happens when the semantics of the thing itself change (i.e. an The requirement here really comes from the spec itself: Is the main issue that the Model doesn't give access to the containing property? How are you planning to tackle this currently? |
Just started this morning and I'm going with your suggestion. I believe each rule is told the name of the containing field as well as the data and model being validated so hopefully it's straightforward to implement. |
Ok great! |
@nickevansuk - would you mind if I swap the order of the property name and the modality fields? So for example with Organization it would be |
Sure @henryaddison sounds good to me! |
Requirement
Add additional flexibility to imperativeConfiguration to allow for the containing property name to be considered when setting required fields for a type.
This functionality would mean that, for example, validating the below
Organization
type would depend on the property within which it was found - e.g."broker"
.Suggested design
Use
imperativeConfigurationWithContext
within the model files, which includes a map withinrequiredFields
,recommendedFields
,shallNotInclude
andrequiredOptions
. This is an additional map of property names (see example below). These changes already exist dormantly in Organization.json and Person.json - just remove the placeholder empty"imperativeConfiguration"
.Implementation hints
Implementation of this likely requires changes to
src/rules/core/required-optional-fields-rule.js
,src/rules/core/required-fields-rule.js
,src/rules/core/recommended-fields-rule.js
, andsrc/rules/core/shall-not-include-fields-rule.js
withindata-model-validator
.Example
The text was updated successfully, but these errors were encountered: