An Integer (number without decimal digits)

Example

const int      = Integer.create(42, { name: 'MyInteger' });
const roundInt = Integer.create(42.6, { round: 'floor' });
const rangeInt = Integer.create(42, { min: 12, max: 43 });

// extract the Result:
if (int.isSuccess()) {
console.log(int.getValue()) // Integer { _value: 42 }
}

Fails

  • if not a valid integer
  • if the value has not allowed decimal digits
  • if the value is not inside the interval

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 not allowed decimal digits

    Fails

    if the value is not inside the interval

    Parameters

    • value: number

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

    • Optional options: IntegerOptions

      constraints the value has to fulfill

    Returns Result<number>

Generated using TypeDoc