Kit
Functions

assertValidBaseString

assertValidBaseString(alphabet, testValue, givenValue?): void

Asserts that a given string contains only characters from the specified alphabet.

This function validates whether a string consists exclusively of characters from the provided alphabet. If the validation fails, it throws an error indicating the invalid base string.

Parameters

ParameterTypeDescription
alphabetstringThe allowed set of characters for the base encoding.
testValuestringThe string to validate against the given alphabet.
givenValue?stringThe original string provided by the user (defaults to testValue).

Returns

void

Throws

If testValue contains characters not present in alphabet.

Example

Validating a base-8 encoded string.

assertValidBaseString('01234567', '123047'); // Passes
assertValidBaseString('01234567', '128');    // Throws error

On this page