An Identifier used for Entitied

Example

const id      = Identifier.create('foo', { name: 'MyID' });
const sizeId = Identifier.create('long_enough', { min: 3, max: 69 });
const regexId = Identifier.create('foo', { regex: /oo/ });

// extract the Result:
if (id.isSuccess()) {
console.log(id.getValue()) // Identifier { _value: 'foo' }
}

Fails

  • if the value is not a string or empty
  • if the value is not matching the regex
  • if the value's length is not inside the interval

Hierarchy

Accessors

Methods

  • Returns

    the value if the validation was successful

    Fails

    if not a string or empty

    Fails

    if the value doesn't fit the given enum / range

    Fails

    if the value is not matching the regex

    Fails

    if the value's length is not inside the interval

    Parameters

    • value: string

      to be validated as a not empty string with the corresponding constraints (options)

    • Optional options: NonEmptyStringOptions

      constraints the value has to fulfill

    Returns Result<string>

Generated using TypeDoc