Repository navigation
v0.4.0
@cookbook/pathkit
0.4.0
Minor Changes
-
dcc0878: Add support for numeric value constraints with the new
minandmaxconstraints.Examples:
{ pattern: '/products/{value:decimal:max(10)}', path: '/products/9.99', matches: { match: true, params: { value: '9.99' }, }, } { pattern: '/products/{value:decimal:min(1)}', path: '/products/9.99', matches: { match: true, params: { value: '9.99' }, }, } { pattern: '/products/{value:decimal:min(1):max(10)}', path: '/products/9.99', matches: { match: true, params: { value: '9.99' }, }, }
Both constraints expect a numeric argument and validate the route parameter value itself.
minvalidates that the parameter value is greater than or equal to the specified number, whilemaxvalidates that it is less than or equal to the specified number.These constraints are different from
minlengthandmaxlength, which validate the length of the parameter value instead. -
21e7658: Add support for minimum- and maximum-length route parameters through the new
minlengthandmaxlengthconstraints.Usage:
/product/{slug:minlength(3)} /product/{slug:maxlength(50)} /product/{slug:minlength(3):maxlength(50)}Both constraints expect a positive integer argument.
minlengthvalidates that the route parameter value has at least the specified number of characters, whilemaxlengthvalidates that it has no more than the specified number of characters. -
64d4844: Add support for UUID route parameters with the new
uuidconstraint.Examples:
{ pattern: '/users/{id:uuid}', path: '/users/7d444840-9dc0-11d1-b245-5ffdce74fad2', matches: { match: true, params: { id: '7d444840-9dc0-11d1-b245-5ffdce74fad2' }, }, }
The
uuidconstraint validates that the route parameter value matches the canonical UUID format:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
This constraint accepts UUID-like values such as UUID v1, v3, v4, and v5, as long as they use the standard hyphenated UUID format.