Skip to content

Validators

Source

Validation helpers for account names and blockchain addresses.

validateAccountName

ts
validateAccountName(name: string, maxLength?: number): { isValid: boolean; error?: string }

Validates a wallet or account name.

Parameters:

NameTypeRequiredDescription
namestringYesAccount name to validate.
maxLengthnumberNoMaximum allowed length. Defaults to 30.

Returns: { isValid: boolean; error?: string }error is set if isValid is false.

Constraints:

  • Must be non-empty after trimming.
  • Must not exceed maxLength characters.
  • Must not contain forbidden filesystem characters: < > : " / \ | ? *.

isAddress

ts
isAddress(address: string): address is Address

Type guard that checks if a string is a valid Address. Runs the full decode + checksum validation.

Parameters:

NameTypeRequiredDescription
addressstringYesString to check.

Returns: booleantrue if the string is a valid Address.

validateAddress

ts
validateAddress(address: string): { isValid: boolean; errorCode?: AddressValidationErrorCode }

Performs detailed multi-step validation of an ASI address.

Parameters:

NameTypeRequiredDescription
addressstringYesAddress string to validate.

Returns: { isValid: boolean; errorCode?: AddressValidationErrorCode }.

Validation steps (in order):

StepErrorCodeCheck
1INVALID_PREFIXMust start with "1111"
2INVALID_LENGTHLength must be between 50 and 54 characters
3INVALID_ALPHABETMust contain only alphanumeric characters
4INVALID_BASE58Must use valid Base58 alphabet (no 0, O, I, l)
5INVALID_HEX_LENGTHDecoded hex must be 80 characters (72 payload + 8 checksum)
6NON_CANONICALRe-encoding the decoded bytes must produce the same address
7INVALID_CHAIN_PREFIXPayload must start with ASI chain prefix
8INVALID_CHECKSUMBlake2b-256 of payload — first 8 hex chars must match checksum

ASI:Chain DevNet - Development Network