The following table lists the options for constraining route parameters by data type and range.
Note that it is also possible to create your own custom constraint
Constraint | Description | Example |
---|---|---|
alpha |
Matches uppercase or lowercase Latin alphabet characters (a-z, A-Z) | {title:alpha} |
bool 1 |
Matches a Boolean value. | {isActive:bool} |
int 1 |
Matches a 32-bit integer value. | {id:int} |
datetime 1 |
Matches a DateTime value. | {startdate:datetime} |
decimal 1 |
Matches a decimal value. | {cost:decimal} |
double 1 |
Matches a 64-bit floating-point value. | {latitude:double} |
float 1 |
Matches a 32-bit floating-point value. | {x:float} |
long 1 |
Matches a 64-bit integer value. | {x:long} |
guid 1 |
Matches a GUID value. | {id:guid} |
length |
Matches a string with the specified length or within a specified range of lengths. | {key:length(8)} {postcode:length(6,8)} |
min |
Matches an integer with a minimum value. | {age:min(18)} |
max |
Matches an integer with a maximum value. | {height:max(10)} |
minlength |
Matches a string with a minimum length. | {title:minlength(2)} |
maxlength |
Matches a string with a maximum length. | {postcode:maxlength(8)} |
range |
Matches an integer within a range of values. | {month:range(1,12)} |
regex |
Matches a regular expression. | {postcode:regex(^[A-Z]{2}\d\s?\d[A-Z]{2}$)} |
Notes
- Can be made optional by adding
?
after the constraint e.gid:int?