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

Enforcing domain invariants #40

Open
blelump opened this issue Feb 6, 2024 · 1 comment
Open

Enforcing domain invariants #40

blelump opened this issue Feb 6, 2024 · 1 comment
Labels

Comments

@blelump
Copy link
Member

blelump commented Feb 6, 2024

Problem overview

There are cases to ensure consistency and integrity of the underlying data model to execute more sophisticated rules on the data itself. They are not supported by OCA in any way, among other things:

  • each entity has a unique ID number
  • check digit meets an identification number
  • device type X has ABC additionally built-in, whereas Y does not

What's the DSWG's perspective on the above business rules, and what is the best place to enforce them? In particular, whether it is still OCA scope.

@pknowl
Copy link
Collaborator

pknowl commented Mar 16, 2024

@blelump Is this the type of overlay you are thinking of for an Invariant Overlay?

{
  "capture_base":"EuQXuO3q0Bbgb_h4RgE37xRvdDXqoYZpFIApL7gUMc0g",
  "digest":"EAKY23aWiy2WSij7R5L0teOsUj35tZiaUOE89d4oi62s",
  "type":"spec/overlays/invariant/1.0",
  "attribute_invariants":{
    "age":"1 <= age <= 125",
    "gender":"gender in ['M', 'F', 'X']",
    "membershipType":"membershipType in ['PREM', 'BASC']",
    "email":"regex('[\\w.-]+@[\\w.-]+\\.\\w+')",
    "registrationDate":"registrationDate <= currentDate()",
    "isActive":"isActive in [0, 1]",
    "profileImage":"profileImage format is 'image/jpeg' or profileImage is absent",
    "interests":"all interests in ['HIKE', 'READ', 'COOK', 'MUSC', 'TRVL', 'SPRT'] and no duplicates"
  }
}

If so, feel free to edit the code snippet as we can use it in an associated RFC

@mitfik mitfik added the v2 label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants