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

support for type constraints #607

Open
lmorg opened this issue Jun 4, 2023 · 2 comments
Open

support for type constraints #607

lmorg opened this issue Jun 4, 2023 · 2 comments
Labels
design question This is where the murex devs can raise a feature idea or discuss a problem with the community enhancement New features

Comments

@lmorg
Copy link
Owner

lmorg commented Jun 4, 2023

Describe the problem:
Add support for custom types with type constraints.

Possible ways to implement:
eg

datatype yyyymmdd {
  inherit: str
  constraint: %({
    -> regexp 'm/[0-9]{4}-[0-9]{2}-[0-9]{2}/'
  })
}

Additional context:

  • inherit will be the built in data type (marshallers et al) to use for that data type.
  • contraint will be a Murex code block that takes the data as value from STDIN and returns a non-zero exitnum if the constraint isn't met. STDOUT and/or STDERR will be output to terminal if constraint isn't met.
@lmorg lmorg added enhancement New features design question This is where the murex devs can raise a feature idea or discuss a problem with the community labels Jun 4, 2023
@lmorg
Copy link
Owner Author

lmorg commented Jul 8, 2023

A little more thought on this feature:

  • The function should be called constraint
  • Which means we cannot have constraint as a property (gets a little repetitive otherwise). So I've opted for Validation instead
constraint yyyymmdd {
    Inherit: str
    Validation: '{
        -> regexp (m/[0-9]{4}-[0-9]{2}-[0-9]{2}/)
    }'
}

@lmorg
Copy link
Owner Author

lmorg commented Dec 10, 2023

Given how expressions are now first class citizens, Validation should probably be passed as a variable rather than a pipe. eg

constraint yyyymmdd {
    Inherit: str
    Expression: '$VALUE =~ "[0-9]{4}-[0-9]{2}-[0-9]{2}"'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design question This is where the murex devs can raise a feature idea or discuss a problem with the community enhancement New features
Projects
None yet
Development

No branches or pull requests

1 participant