Options
All
  • Public
  • Public/Protected
  • All
Menu

@briza/wegood

Index

References

Renames and re-exports Validator

Functions

  • date(errorMsg: string, start: undefined | null | string | number | Date, end: undefined | null | string | number | Date, transform?: (value: string) => Date, todayDate?: Date): ValidationRule
  • Date validation rule. The value passed into the validation function must be a Date object or ISO date string: yyyy-mm-dd. Or a custom transform function can be used to perform custom string to date conversion.

    Parameters

    • errorMsg: string

      Error message.

    • start: undefined | null | string | number | Date

      Start date boundary. If null or undefined, there is no start boundary.

    • end: undefined | null | string | number | Date

      End date boundary. If null or undefined, there is no end boundary.

    • Optional transform: (value: string) => Date

      Optional custom transform function, to convert the testing value into date object.

        • (value: string): Date
        • Parameters

          • value: string

          Returns Date

    • Optional todayDate: Date

      Optional Today's date to be used as reference validating ranges. If not provided, the start of the day in the current runtime timezone will be used.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • equal(errorMsg: string, arg: any): ValidationRule
  • Equal validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • arg: any

      Matcher object, or a custom equality predicate function, fn(val) returning true|false (equal / not equal).

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • exclude(errorMsg: string, exclusions: (string | number | boolean)[]): ValidationRule
  • Exclude validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • exclusions: (string | number | boolean)[]

      List of exclusions.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • include(errorMsg: string, inclusions: (string | number | boolean)[]): ValidationRule
  • Include validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • inclusions: (string | number | boolean)[]

      List of inclusions.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • length(errorMsg: string, min: undefined | null | number, max: undefined | null | number): ValidationRule
  • Length validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • min: undefined | null | number

      Minimal length. If null or undefined, there is no min length.

    • max: undefined | null | number

      Maximal length. If null or undefined, there is no max length.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • pattern(errorMsg: string, pattern: RegExp): ValidationRule
  • Pattern validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • pattern: RegExp

      Regular expression.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • present(errorMsg: string): ValidationRule
  • Present validation rule.

    Parameters

    • errorMsg: string

      Error message.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • range(errorMsg: string, min: undefined | null | number, max: undefined | null | number): ValidationRule
  • Range validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • min: undefined | null | number

      Minimal boundary. If null or undefined, there is no min boundary.

    • max: undefined | null | number

      Maximal boundary. If null or undefined, there is no max boundary.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

  • year(errorMsg: string, start: undefined | null | string | number, end: undefined | null | string | number): ValidationRule
  • Year validation rule.

    Parameters

    • errorMsg: string

      Error message.

    • start: undefined | null | string | number

      Start year boundary. If null or undefined, there is no start boundary.

    • end: undefined | null | string | number

      End year boundary. If null or undefined, there is no end boundary.

    Returns ValidationRule

    validation function, fn(value) => true|string, returns true when valid, error message otherwise.

Generated using TypeDoc