Regex constraints in abstract attributes

Hello,

Consider the query

insert
$r isa resource, has hex "00t";

This query is correctly validated (and the data not inserted) in the schema

define
hex sub attribute, value string,
   regex "^([0-9a-f]{2})+$";

resource sub entity,
   owns hex;

However, an analogous query with invalid hex values succeeds in the following schema

define
hex sub attribute, value string, abstract,
   regex "^([0-9a-f]{2})+$";

checksum sub hex;
address sub hex;

resource sub entity,
   owns checksum,
   owns address;

This suggests that regex constraints defined for abstract attributes are ignored by its subtypes.

  1. Is this the expected behavior?
  2. In that case, out of curiosity, could you please roughly elaborate on the reasons for such a decision?

I think that the second model would be useful, e.g., to define a “data type” (such as hex) as a super type of several attributes in a large schema. The alternative seems to be defining the regex for each subtype.

define
hex sub attribute, value string, abstract;

checksum sub hex, regex "^([0-9a-f]{2})+$";
address sub hex, regex "^([0-9a-f]{2})+$";
...

Thanks in advance

No.

It works as you’d expect in 3.0. Is it important to you that we fix it in a 2.x release? Or can you workaround it till 3.0 GA by declaring the regex on each of the subtypes?

I can happily wait for the fix in v3.0. I have an alternative schema based on the features on the roadmap, so I will keep the compact version above for when v3.0 sees the light.

Thanks for the nice work over there :).

1 Like