A special Integer with the predefined interval [0,∞]

which will not accept and parse floating point numbers.

Example

const numId    = NumericId.create(11, {name: 'MyID'});
const maxNumId = NumericId.create(420, {max: 421});

// extract the Result:
if (numId.isSuccess()) {
console.log(numId.getValue()) // NumericId { _value: 11 }
}

Fails

  • if not a valid integer
  • if the value has decimal digits
  • if the value is not inside the interval (at least positive)

Hierarchy

Accessors

Methods

  • compares 2 Lists of ValueObjects / values on equality

    Returns

    true if the lists are equal

    Type Parameters

    • ValueType

    Parameters

    • a: ValueObject<ValueType>[]

      the list of ValueObjects to compare with

    • b: ValueObject<ValueType>[] | ValueType[]

      a list of ValueObjects / values for comparison

    Returns boolean

  • Returns

    the value if the validation was successful

    Fails

    if not a valid integer

    Fails

    if the value has decimal digits

    Fails

    if the value is not inside the interval (at least positive)

    Parameters

    • value: number

      to be validated as an integer with the corresponding constraints (options)

    • Optional options: NumericIdOptions

      constraints the value has to fulfill

    Returns Result<number>

Generated using TypeDoc