Validation Rules
Adopted from ReglDRef normatively adopts and inherits the generic validation rule catalog from the Regl Specification (regl.dev). Rules are attached to model properties as declarative JSON data and evaluated by Regl-compliant runtimes in every language. Failures are blocking errors by default; set severity: "warn" to demote them to non-blocking warnings.
Canonical SpecificationValidation rules belong to Regl
All 40 primitive field validation rules are specified, typed, tested, and maintained by the Regl project (regl.dev). DRef models attach these rules as declarative data while providing higher-level domain modeling, scopes, write authorities, and immutability.
45 of 45 rules
StringText shape & format (Regl)
18| Rule | Parameter | Description | Rule evaluation | Example |
|---|---|---|---|---|
minLength Minimum Length | number | Requires text to be at least {value} characters. | value.length >= param | minLength: 3 |
maxLength Maximum Length | number | Requires text to be no longer than {value} characters. | value.length <= param | maxLength: 255 |
length Exact Length | number | Requires text to be exactly {value} characters. | value.length === param | length: 16 |
pattern Regex Pattern | string | Requires text to match the regular expression: {value}. | new RegExp(param).test(value) | pattern: "^[a-z0-9_]+quot; |
contains Contains Text | string | Requires text to contain the substring: {value}. | value.includes(param) | contains: "@" |
startsWith Starts With | string | Requires text to start with: {value}. | value.startsWith(param) | startsWith: "usr_" |
endsWith Ends With | string | Requires text to end with: {value}. | value.endsWith(param) | endsWith: ".json" |
email Email Address | none | Requires a valid email address format. | RFC5322Regex.test(value) | email: true |
url URL | none | Requires a valid HTTP or HTTPS URL. | new URL(value) | url: true |
uuid UUID | none | Requires a valid UUID format. | UUIDRegex.test(value) | uuid: true |
languageCode Language Code | none | Requires a well-formed BCP-47 language tag. | Bcp47TagRegex.test(value) | languageCode: true |
lowercase Lowercase | none | Requires all characters to be lowercase. | value === value.toLowerCase() | lowercase: true |
uppercase Uppercase | none | Requires all characters to be uppercase. | value === value.toUpperCase() | uppercase: true |
trimmed Trimmed | none | Requires no leading or trailing whitespace. | value === value.trim() | trimmed: true |
notEmpty Not Empty | none | Requires text to contain at least one non-whitespace character. | value.trim().length > 0 | notEmpty: true |
text Human-Readable Text | none | Marks a field as human-readable text. | marker — no value-level enforcement; parameter checked against the BCP-47 tag pattern | text: "en" |
notNull Not Null | none | Requires the value to be present and not null. | value !== null && value !== undefined | notNull: true |
enum Allowed Values | array | Restricts the value to a predefined list of allowed strings: {value}. | param.includes(value) | enum: ["USD", "EUR", "GBP"] |
NumberNumeric bounds & steps (Regl)
10| Rule | Parameter | Description | Rule evaluation | Example |
|---|---|---|---|---|
greaterThan Greater Than | number | Requires the number to be strictly greater than {value}. | value > param | greaterThan: 0 |
greaterThanOrEqual Greater Than or Equal | number | Requires the number to be greater than or equal to {value}. | value >= param | greaterThanOrEqual: 18 |
lessThan Less Than | number | Requires the number to be strictly less than {value}. | value < param | lessThan: 1000 |
lessThanOrEqual Less Than or Equal | number | Requires the number to be less than or equal to {value}. | value <= param | lessThanOrEqual: 100 |
positive Positive Number | none | Requires a number strictly greater than zero. | value > 0 | positive: true |
negative Negative Number | none | Requires a number strictly less than zero. | value < 0 | negative: true |
positiveInteger Positive Integer | none | Requires a whole number strictly greater than zero. | Number.isInteger(value) && value > 0 | positiveInteger: true |
negativeInteger Negative Integer | none | Requires a whole number strictly less than zero. | Number.isInteger(value) && value < 0 | negativeInteger: true |
multipleOf Multiple Of | number | Requires the number to be a multiple of {value}. | value % param === 0 | multipleOf: 5 |
precision Decimal Precision | number | Restricts the maximum number of decimal places to {value}. | getDecimals(value) <= param | precision: 2 |
TemporalDates, times, and timestamps (Regl)
8| Rule | Parameter | Description | Rule evaluation | Example |
|---|---|---|---|---|
dateFormat Date Format | string | Requires date/time string to match format pattern: {value}. | matchesFormat(value, param) | dateFormat: "YYYY-MM-DD" |
isoDate ISO Date | none | Requires a valid ISO-8601 calendar date (YYYY-MM-DD). | isIsoDate(value) | isoDate: true |
isoDateTime ISO Date-Time | none | Requires a valid ISO-8601 date-time timestamp. | isIsoDateTime(value) | isoDateTime: true |
isoTime ISO Time | none | Requires a valid ISO-8601 time (HH:mm:ss). | isIsoTime(value) | isoTime: true |
after After Date | string | Requires date/time to be chronologically after {value}. | parseInstant(value) > parseInstant(param) | after: "2025-01-01" |
before Before Date | string | Requires date/time to be chronologically before {value}. | parseInstant(value) < parseInstant(param) | before: "2025-12-31" |
epoch Epoch Seconds | none | Requires a whole-number Unix timestamp in seconds. | Number.isInteger(value) && isEpochSeconds(value) | epoch: true |
epochMillis Epoch Milliseconds | none | Requires a whole-number Unix timestamp in milliseconds. | Number.isInteger(value) && isEpochMillis(value) | epochMillis: true |
ListCollection cardinality (Regl)
2| Rule | Parameter | Description | Rule evaluation | Example |
|---|---|---|---|---|
range List Size Range | range | Restricts the number of items in a list to the range {value}. | array.length >= (min ?? -Inf) && array.length <= (max ?? Inf) | range: { min: 1, max: 50 } |
unique Unique Items | none | Requires all items in the list to be distinct. | new Set(array).size === array.length | unique: true |
BooleanBinary flags (Regl)
2| Rule | Parameter | Description | Rule evaluation | Example |
|---|---|---|---|---|
isTrue Is True | none | Requires a boolean value to be true. | value === true | isTrue: true |
isFalse Is False | none | Requires a boolean value to be false. | value === false | isFalse: true |
DRef GovernanceModel attributes & write guards (DRef)
5| Rule | Parameter | Description | Rule evaluation | Example |
|---|---|---|---|---|
immutable Immutable | none | Forbids modification of this field after creation. Domain-level write guard, not a value-level validation rule. | writeGuard(field) | immutable: true |
count Instance Count Range | range | Inclusive bounds on total instances permitted in the system (either bound optional). min defaults to 0 when omitted; an absent count means unbounded. | totalInstances >= (min ?? -Inf) && totalInstances <= (max ?? Inf) | count: { max: 1 } |
ttl Retention TTL | string | Retention duration as integer + unit — s (seconds), m (minutes), h (hours), d (days), M (months), y (years), e.g. 5s, 2m, 24h, 30d, 1M. An omitted ttl is lifecycle-manager-determined (persistent by default) and is not modelled in DRef. | now() - createdAt <= parseTtl(param) | ttl: "30d" |
authority Authority | enum: client | internal | external | Designates the authoritative origin source for instance creation. | ["client", "internal", "external"].includes(param) | authority: "client" |
property.authority Property Authority | enum: client | internal | external | Per-property principal permitted to set the field's value; an omitted authority means any principal may write it. Enforced by write validation (validateWrite/validateWriteOrThrow). | ["client", "internal", "external"].includes(param) | property.authority: "internal" |