murex
murex copied to clipboard
support for type constraints
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:
-
inheritwill be the built in data type (marshallers et al) to use for that data type. -
contraintwill 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.
A little more thought on this feature:
- The function should be called
constraint - Which means we cannot have
constraintas a property (gets a little repetitive otherwise). So I've opted forValidationinstead
constraint yyyymmdd {
Inherit: str
Validation: '{
-> regexp (m/[0-9]{4}-[0-9]{2}-[0-9]{2}/)
}'
}
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}"'
}