typedb / typeql

TypeQL: the power of programming, in your database
https://typedb.com
Mozilla Public License 2.0
219 stars 46 forks source link

Attribute value restrictions #271

Open PatLechevallier opened 2 years ago

PatLechevallier commented 2 years ago

Problem to Solve

TypeDB has regex for string attributes but no Numeric Attribute Validation (min, max, range)

Current Workaround

An idea should be to

define max-long-value sub attribute, value long; measure sub attribute, value long, has max-value;

And to evaluate the statement on the client side.

Or define an max-error entity in TypeDB and define a rule that would raise an error (create a relation between the attribute and error code). But still require the client to pull the error entity.

Proposed Solution

Support Natively the constraint if possible of course. define item owns measure, must-be <= {numeric value}; or define item owns measure, max {numerix value}; or more original, let the modeler define his own rules that raise error in the system as described above.

flyingsilverfin commented 1 year ago

Moving to TypeQL repository

flyingsilverfin commented 1 year ago

We can introduce a set of value restriction annotations in TypeQL.

@range(start inclusive, end inclusive) @regex (change from the current regex keyword)

and others we can think of in the future.

sanmai-NL commented 1 week ago

@flyingsilverfin I can't find documentation on the regex syntax supported. Just referencing the regex engine used would be helpful already.

flyingsilverfin commented 5 days ago

@sanmai-NL is this for 2.0 or 3.0? We basically push the execution to Java in (in 2.x) or Rust (3.x)

sanmai-NL commented 5 days ago

Both are relevant but for now 2 is of immediate concern to us. So the java.util.regex package applies?

flyingsilverfin commented 5 days ago

Yep!