I have a type similar to:
type ID is new String (1 .. 7);
-- Example: 123-456
How can I specify that format in code, either with Ada or SPARK?
I was thinking about Static_Predicate
, but the condition that the string must start with 3 positive integers followed by a dash followed by another set of 3 positive integers can't be described with a Static_Predicate
expression.
You have to use a
Dynamic_Predicate
for this:I'm using this quite a bit myself, but I mostly make the types subtypes of
String
instead of actual new types.