index/functions/validateTokenName.md
validateTokenName(
tokenName,field,constraint):void
Validates a token name with constraint-specific error messages
Enhanced version that provides the exact length constraint in error messages. This is the recommended function for service methods.
token name
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenName | unknown | Token name to validate |
field | string | Field name for error messages |
constraint | TokenNameConstraint | The route's token name constraint |
token name constraint
Returns
void
Throws
If token name is invalid
Example
// Throws: "tokenName must be 1-25 letters and digits"
validateTokenName('my-token', 'tokenName', TOKEN_NAME_DTO_CONSTRAINT);
Since
6.12.0