Interface NumericValidationBuilderBase<T, ExcludedMethods>

Interface for numeric validation methods without any exclusions

interface NumericValidationBuilderBase<T, ExcludedMethods> {
    gt(value, errorMessage?): NumericValidationBuilder<T, "gt" | ExcludedMethods | "positive">;
    gte(value, errorMessage?): NumericValidationBuilder<T, ExcludedMethods | "gte">;
    lt(value, errorMessage?): NumericValidationBuilder<T, "lt" | ExcludedMethods | "negative">;
    lte(value, errorMessage?): NumericValidationBuilder<T, ExcludedMethods | "lte">;
    negative(errorMessage?): NumericValidationBuilder<T, "lt" | ExcludedMethods | "negative">;
    positive(errorMessage?): NumericValidationBuilder<T, "gt" | ExcludedMethods | "positive">;
}

Type Parameters

  • T

  • ExcludedMethods extends string = never

Methods

  • Validates that a numeric field is greater than the specified value

    ⚠️ Only applicable for integer or float fields

    Parameters

    • value: number

      The value that the field must be greater than

    • Optional errorMessage: string

      Optional custom error message

    Returns NumericValidationBuilder<T, "gt" | ExcludedMethods | "positive">

    Example

    // Integer field example
    a.integer().validate(v => v.gt(10, 'Integer must be greater than 10'))

    // Float field example
    a.float().validate(v => v.gt(3.14, 'Float must be greater than 3.14'))
  • Validates that a numeric field is greater than or equal to the specified value

    ⚠️ Only applicable for integer or float fields

    Parameters

    • value: number

      The value that the field must be greater than or equal to

    • Optional errorMessage: string

      Optional custom error message

    Returns NumericValidationBuilder<T, ExcludedMethods | "gte">

    Example

    // Integer field example
    a.integer().validate(v => v.gte(10, 'Integer must be greater than or equal to 10'))

    // Float field example
    a.float().validate(v => v.gte(3.14, 'Float must be greater than or equal to 3.14'))
  • Validates that a numeric field is less than the specified value

    ⚠️ Only applicable for integer or float fields

    Parameters

    • value: number

      The value that the field must be less than

    • Optional errorMessage: string

      Optional custom error message

    Returns NumericValidationBuilder<T, "lt" | ExcludedMethods | "negative">

    Example

    // Integer field example
    a.integer().validate(v => v.lt(10, 'Integer must be less than 10'))

    // Float field example
    a.float().validate(v => v.lt(3.14, 'Float must be less than 3.14'))
  • Validates that a numeric field is less than or equal to the specified value

    ⚠️ Only applicable for integer or float fields

    Parameters

    • value: number

      The value that the field must be less than or equal to

    • Optional errorMessage: string

      Optional custom error message

    Returns NumericValidationBuilder<T, ExcludedMethods | "lte">

    Example

    // Integer field example
    a.integer().validate(v => v.lte(10, 'Integer must be less than or equal to 10'))

    // Float field example
    a.float().validate(v => v.lte(3.14, 'Float must be less than or equal to 3.14'))
  • Validates that a numeric field is negative

    ⚠️ Only applicable for integer or float fields

    Parameters

    • Optional errorMessage: string

      Optional custom error message

    Returns NumericValidationBuilder<T, "lt" | ExcludedMethods | "negative">

    Example

    // Integer field example
    a.integer().validate(v => v.negative('Integer must be negative'))

    // Float field example
    a.float().validate(v => v.negative('Float must be negative'))
  • Validates that a numeric field is positive

    ⚠️ Only applicable for integer or float fields

    Parameters

    • Optional errorMessage: string

      Optional custom error message

    Returns NumericValidationBuilder<T, "gt" | ExcludedMethods | "positive">

    Example

    // Integer field example
    a.integer().validate(v => v.positive('Integer must be positive'))

    // Float field example
    a.float().validate(v => v.positive('Float must be positive'))