Skip to content
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

Conditional Restrictions - Add conditional restriction logic to field meta schemas and implement validation logic #223

Merged
merged 21 commits into from
Aug 19, 2024

Conversation

joneubank
Copy link
Contributor

@joneubank joneubank commented Aug 19, 2024

Objective

Introduces Conditional Restrictions to the Lectern meta schema. All field types can now optionally contain conditions for applying restrictions based on the value of other fields in the same record.

The validation library has been updated to consider any conditional restrictions when resolving which restrictions need to be applied to a field.

Details

Dictionary

  • Conditional Restrictions added to restrictions object type for all fields types (string/number/integer/boolean)
  • Conditional Restriction match rules added:
    • codeList
    • count
    • exists
    • range
    • regex
    • value
  • Reference replacement will now properly replace reference tags in:
    • recursively through nested meta objects
    • conditional restrictions, including nested recursive restrictions
    • codeList and regex match rules
  • Formally removes script restrictions
  • Moves unique restriction to be a property of a field, not part of restrictions
  • Tests added:
    • recursive reference replacement
    • ensure conditional restrictions are parsed correctly by meta schemas

Validation

  • Conditional restrictions are resolved based on value of fields in record
  • Tests added:
    • conditional restriction test match rules
    • conditional restriction array case matching

Scripts

  • JSON Schema generation script will now create a reference definition for field each field and each field's restriction types.
  • New JSON Schema definition generated for the Lectern Dictionary, including conditional restriction types.

Github Issue Tracking

This accomplishes the majority of tasks listed in #209 .
The missing tasks will be moved into separate tickets to be completed separately:

  • compare restriction
  • compare conditional match rule
  • condition arrayFieldCase to modify the rules for matching values in a field with an array of values.

These are breaking changes to the meta schema that need to be published as a major release. A document should be added to the repo describing these changes.
- performs code list and regex reference replacement recursively through conditional restrictions
- performs reference replacement recursively through meta objects
- applies conditional restriction checks when resolving restriction rules for each field
- WIP: still requires many tests
- Generic conditional restriction function was removed because it could not be interpretted by the json schema generator
- Although there is repeated code, directly writing the typed conditional restriction type schemas is easier to parse and hopefully maintain. They have their types enforced by a generic type even if the schema itself is not generated through a function.
@joneubank joneubank marked this pull request as ready for review August 19, 2024 14:29
@joneubank joneubank requested a review from leoraba August 19, 2024 14:31
Copy link
Contributor

@leoraba leoraba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@joneubank joneubank merged commit 49c8f00 into develop Aug 19, 2024
2 checks passed
@joneubank joneubank deleted the feat/209-conditional-restrictions branch August 19, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants