dref
v1.0.0
specification.json

Validation Rules

Adopted from Regl

DRef 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
RuleParameterDescriptionRule evaluationExample
minLength
Minimum Length
numberRequires text to be at least {value} characters.value.length >= paramminLength: 3
maxLength
Maximum Length
numberRequires text to be no longer than {value} characters.value.length <= parammaxLength: 255
length
Exact Length
numberRequires text to be exactly {value} characters.value.length === paramlength: 16
pattern
Regex Pattern
stringRequires text to match the regular expression: {value}.new RegExp(param).test(value)pattern: "^[a-z0-9_]+
quot;
contains
Contains Text
stringRequires text to contain the substring: {value}.value.includes(param)contains: "@"
startsWith
Starts With
stringRequires text to start with: {value}.value.startsWith(param)startsWith: "usr_"
endsWith
Ends With
stringRequires text to end with: {value}.value.endsWith(param)endsWith: ".json"
email
Email Address
noneRequires a valid email address format.RFC5322Regex.test(value)email: true
url
URL
noneRequires a valid HTTP or HTTPS URL.new URL(value)url: true
uuid
UUID
noneRequires a valid UUID format.UUIDRegex.test(value)uuid: true
languageCode
Language Code
noneRequires a well-formed BCP-47 language tag.Bcp47TagRegex.test(value)languageCode: true
lowercase
Lowercase
noneRequires all characters to be lowercase.value === value.toLowerCase()lowercase: true
uppercase
Uppercase
noneRequires all characters to be uppercase.value === value.toUpperCase()uppercase: true
trimmed
Trimmed
noneRequires no leading or trailing whitespace.value === value.trim()trimmed: true
notEmpty
Not Empty
noneRequires text to contain at least one non-whitespace character.value.trim().length > 0notEmpty: true
text
Human-Readable Text
noneMarks a field as human-readable text.marker — no value-level enforcement; parameter checked against the BCP-47 tag patterntext: "en"
notNull
Not Null
noneRequires the value to be present and not null.value !== null && value !== undefinednotNull: true
enum
Allowed Values
arrayRestricts the value to a predefined list of allowed strings: {value}.param.includes(value)enum: ["USD", "EUR", "GBP"]
NumberNumeric bounds & steps (Regl)
10
RuleParameterDescriptionRule evaluationExample
greaterThan
Greater Than
numberRequires the number to be strictly greater than {value}.value > paramgreaterThan: 0
greaterThanOrEqual
Greater Than or Equal
numberRequires the number to be greater than or equal to {value}.value >= paramgreaterThanOrEqual: 18
lessThan
Less Than
numberRequires the number to be strictly less than {value}.value < paramlessThan: 1000
lessThanOrEqual
Less Than or Equal
numberRequires the number to be less than or equal to {value}.value <= paramlessThanOrEqual: 100
positive
Positive Number
noneRequires a number strictly greater than zero.value > 0positive: true
negative
Negative Number
noneRequires a number strictly less than zero.value < 0negative: true
positiveInteger
Positive Integer
noneRequires a whole number strictly greater than zero.Number.isInteger(value) && value > 0positiveInteger: true
negativeInteger
Negative Integer
noneRequires a whole number strictly less than zero.Number.isInteger(value) && value < 0negativeInteger: true
multipleOf
Multiple Of
numberRequires the number to be a multiple of {value}.value % param === 0multipleOf: 5
precision
Decimal Precision
numberRestricts the maximum number of decimal places to {value}.getDecimals(value) <= paramprecision: 2
TemporalDates, times, and timestamps (Regl)
8
RuleParameterDescriptionRule evaluationExample
dateFormat
Date Format
stringRequires date/time string to match format pattern: {value}.matchesFormat(value, param)dateFormat: "YYYY-MM-DD"
isoDate
ISO Date
noneRequires a valid ISO-8601 calendar date (YYYY-MM-DD).isIsoDate(value)isoDate: true
isoDateTime
ISO Date-Time
noneRequires a valid ISO-8601 date-time timestamp.isIsoDateTime(value)isoDateTime: true
isoTime
ISO Time
noneRequires a valid ISO-8601 time (HH:mm:ss).isIsoTime(value)isoTime: true
after
After Date
stringRequires date/time to be chronologically after {value}.parseInstant(value) > parseInstant(param)after: "2025-01-01"
before
Before Date
stringRequires date/time to be chronologically before {value}.parseInstant(value) < parseInstant(param)before: "2025-12-31"
epoch
Epoch Seconds
noneRequires a whole-number Unix timestamp in seconds.Number.isInteger(value) && isEpochSeconds(value)epoch: true
epochMillis
Epoch Milliseconds
noneRequires a whole-number Unix timestamp in milliseconds.Number.isInteger(value) && isEpochMillis(value)epochMillis: true
ListCollection cardinality (Regl)
2
RuleParameterDescriptionRule evaluationExample
range
List Size Range
rangeRestricts 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
noneRequires all items in the list to be distinct.new Set(array).size === array.lengthunique: true
BooleanBinary flags (Regl)
2
RuleParameterDescriptionRule evaluationExample
isTrue
Is True
noneRequires a boolean value to be true.value === trueisTrue: true
isFalse
Is False
noneRequires a boolean value to be false.value === falseisFalse: true
DRef GovernanceModel attributes & write guards (DRef)
5
RuleParameterDescriptionRule evaluationExample
immutable
Immutable
noneForbids modification of this field after creation. Domain-level write guard, not a value-level validation rule.writeGuard(field)immutable: true
count
Instance Count Range
rangeInclusive 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
stringRetention 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 | externalDesignates the authoritative origin source for instance creation.["client", "internal", "external"].includes(param)authority: "client"
property.authority
Property Authority
enum: client | internal | externalPer-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"