Skip to main content

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.

Parameters​

ParameterTypeDescription
tokenNameunknownToken name to validate
fieldstringField name for error messages
constraintTokenNameConstraintThe route's 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