lmorg / murex

A smarter shell and scripting environment with advanced features designed for usability, safety and productivity (eg smarter DevOps tooling)
https://murex.rocks
GNU General Public License v2.0
1.46k stars 27 forks source link

support for type constraints #607

Open lmorg opened 1 year ago

lmorg commented 1 year ago

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:

lmorg commented 1 year ago

A little more thought on this feature:

constraint yyyymmdd {
    Inherit: str
    Validation: '{
        -> regexp (m/[0-9]{4}-[0-9]{2}-[0-9]{2}/)
    }'
}
lmorg commented 9 months ago

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}"'
}