Header menu logo ananoid

AlphabetExtensions Type

Contains utilities intended to simplify working with Alphabet in languages other than F#.

Static members

Static member Description

AlphabetExtensions.ToAlphabet(letters)

Full Usage: AlphabetExtensions.ToAlphabet(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.

AlphabetExtensions.ToAlphabetOrThrow(letters)

Full Usage: AlphabetExtensions.ToAlphabetOrThrow(letters)

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

Returns: Alphabet

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: Alphabet
ArgumentOutOfRangeException Raised when the given letters fail to uphold an invariant.

AlphabetExtensions.TryMakeAlphabet(letters, alphabet)

Full Usage: AlphabetExtensions.TryMakeAlphabet(letters, alphabet)

Parameters:
    letters : string - The letter set which will ultimately be used to generate NanoId instances.
    alphabet : outref<Alphabet> - On successful validation, this out parameter will be a Alphabet; otherwise, it will be null.

Returns: bool true if validation succeeded and an Alphabet was created; otherwise, returns false.

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.

alphabet : outref<Alphabet>

On successful validation, this out parameter will be a Alphabet; otherwise, it will be null.

Returns: bool

true if validation succeeded and an Alphabet was created; otherwise, returns false.

AlphabetExtensions.TryParseNanoId(alphabet, value, nanoId)

Full Usage: AlphabetExtensions.TryParseNanoId(alphabet, value, nanoId)

Parameters:
    alphabet : Alphabet - The letters to check against for validity.
    value : string - The raw string to be converted.
    nanoId : outref<NanoId> - On successful parsing, contains a NanoId instance.

Returns: bool true if parsing succeeded; false otherwise.

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 true). However, the resulting NanoId instance will be NanoId.Empty.

alphabet : Alphabet

The letters to check against for validity.

value : string

The raw string to be converted.

nanoId : outref<NanoId>

On successful parsing, contains a NanoId instance.

Returns: bool

true if parsing succeeded; false otherwise.

AlphabetExtensions.TryParseNonEmptyNanoId(alphabet, value, nanoId)

Full Usage: AlphabetExtensions.TryParseNonEmptyNanoId(alphabet, value, nanoId)

Parameters:
    alphabet : Alphabet - The letters to check against for validity.
    value : string - The raw string to be converted.
    nanoId : outref<NanoId> - On successful parsing, contains a NanoId instance.

Returns: bool true if parsing succeeded; false otherwise.

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 false).

alphabet : Alphabet

The letters to check against for validity.

value : string

The raw string to be converted.

nanoId : outref<NanoId>

On successful parsing, contains a NanoId instance.

Returns: bool

true if parsing succeeded; false otherwise.

Type something to start searching.