Header menu logo ananoid

Alphabet Type

Represents a validated set of 'letters' from which an identifier is made (for details, see Alphabet.Validate).

Instance members

Instance member Description

this.Letters

Full Usage: this.Letters

Returns: string

The validated letter set in this instance.

Returns: string

this.MakeNanoId

Full Usage: this.MakeNanoId

Parameters:
    size : int - The length of a generated identifier, in number of characters (note: negative values are changed to zero).

Returns: NanoId

Creates a new NanoId instance of the given size whose letters are taken from the current alphabet.

size : int

The length of a generated identifier, in number of characters (note: negative values are changed to zero).

Returns: NanoId

this.ParseNanoId

Full Usage: this.ParseNanoId

Parameters:
    value : string - The raw string to be converted.

Returns: NanoId option On successful parsing, returns a NanoId instance; otherwise, returns None.

Attempts to convert the given value into a NanoId, using the current alphabet to guide validation.

If the input value is empty (ie: null, zero-length, or consists only of whitespace), parsing is considered to succeed (ie: the method will return Some NanoId.Empty). This mirrors the behavior of Alphabet.MakeNanoId

value : string

The raw string to be converted.

Returns: NanoId option

On successful parsing, returns a NanoId instance; otherwise, returns None.

this.ParseNonEmptyNanoId

Full Usage: this.ParseNonEmptyNanoId

Parameters:
    value : string - The raw string to be converted.

Returns: NanoId option On successful parsing, returns a NanoId instance; otherwise, returns None.

Attempts to convert the given value into a NanoId, using the current alphabet to guide validation.

If the input value is empty (ie: null, zero-length, or consists only of whitespace), parsing is considered to fail (ie: the method will return None).

value : string

The raw string to be converted.

Returns: NanoId option

On successful parsing, returns a NanoId instance; otherwise, returns None.

Static members

Static member Description

Alphabet.Validate(letters)

Full Usage: Alphabet.Validate(letters)

Parameters:
    letters : string - The letter set which will ultimately be used to generate NanoId instances.

Returns: Result<Alphabet, InvalidAlphabet> On successful validation, returns a Alphabet; otherwise, returns a InvalidAlphabet with further details about what went wrong.

Builds a new Alphabet from the given letter set after checking that it upholds certain invariants which are necessary for the algorithm to work well.

An alphabet's letters MUST uphold the following invariants:

  • Is not null
  • Contains at least one (1) non-whitespace letter
  • Contains no more then 255 letters

letters : string

The letter set which will ultimately be used to generate NanoId instances.

Returns: Result<Alphabet, InvalidAlphabet>

On successful validation, returns a Alphabet; otherwise, returns a InvalidAlphabet with further details about what went wrong.

Type something to start searching.