Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Validator

Hierarchy

  • EventEmitter
    • Validator

Index

Constructors

constructor

Properties

Protected _errors

Protected _labels

_labels: Labels

Protected _messages

_messages: InstanceMessages

Protected _normalizers

_normalizers: NormalizerList

Protected _rules

_rules: RuleList

Protected _validating

_validating: boolean = false

Instance

Protected _values

_values: Values

Static _builtinNormalizers

_builtinNormalizers: BuiltinNormalizerList

Static _builtinRules

_builtinRules: BuiltinRuleList

Static _locale

_locale: string = "en"

Static _localeMessages

_localeMessages: DefinedLocaleMessages

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addError

  • addError(field: string, rule: string, result: string | boolean, params: RuleParams): void

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Protected afterValidate

  • afterValidate(filters: string[] | null): void

Protected asyncExecuteTest

  • asyncExecuteTest(rule: string, field: string, value: any, params: RuleParams): Promise<void>

asyncValidate

  • asyncValidate(filter?: string | string[]): Promise<Values>

Protected beforeValidate

  • beforeValidate(filters: string[] | null): void
  • Events

    Parameters

    • filters: string[] | null

    Returns void

clearAllErrors

  • clearAllErrors(): void

clearErrors

  • clearErrors(field: string): void

clearValues

  • clearValues(): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

Protected executeNormalize

  • executeNormalize(name: string, field: string, value: any, params: NormalizeParams, previousValue: any, previousValues: Values): any

Protected executeTest

  • executeTest(sync: boolean, rule: string, field: string, value: any, params: RuleParams, force?: boolean): boolean | string | Promise<string | void>
  • Parameters

    • sync: boolean
    • rule: string
    • field: string
    • value: any
    • params: RuleParams
    • Default value force: boolean = false

    Returns boolean | string | Promise<string | void>

Protected expandNormalizers

Protected expandRules

getAllErrorMessages

getAllErrors

getAsyncRuleKeys

  • getAsyncRuleKeys(): string[]

getErrorMessage

  • getErrorMessage(field: string, rule: string): string | null
  • Parameters

    • field: string
    • rule: string

    Returns string | null

getErrorMessages

  • getErrorMessages(field: string): string[] | null

getErrors

getFilteredValues

  • getFilteredValues(filters?: string[]): Values

getLabel

  • getLabel(field: string): string

getLabels

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getMessages

getNormalizers

Protected getPrecompileErrorMessage

  • getPrecompileErrorMessage(field: string, rule: string, type?: string | null): string | MessageCreator

getRules

getSyncRuleKeys

  • getSyncRuleKeys(): string[]

getValue

  • getValue(field: string): any

getValues

hasErrors

  • hasErrors(field: string): boolean

hasValue

  • hasValue(field: string): boolean

isValid

  • isValid(filter?: string | string[] | null): boolean
  • Parameters

    • Optional filter: string | string[] | null

    Returns boolean

isValidating

  • isValidating(): boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

mappingRuleParams

  • mappingRuleParams(): void

mergeLabels

  • mergeLabels(labels: Labels): void

mergeMessages

mergeNormalizers

mergeRules

mergeValues

  • mergeValues(values: Values): void

normalize

  • normalize(filters?: string | string[]): void
  • Parameters

    • Optional filters: string | string[]

    Returns void

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeError

  • removeError(field: string, rule: string): void
  • Parameters

    • field: string
    • rule: string

    Returns void

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setErrors

setLabels

  • setLabels(labels: Labels): void

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setMessages

setNormalizers

setRules

setValue

  • setValue(field: string, value: any): void

setValues

  • setValues(values: Values): void

Protected syncExecuteTest

  • syncExecuteTest(rule: string, field: string, value: any, params: RuleParams): boolean | string

validate

  • validate(filter?: string | string[]): boolean
  • Parameters

    • Optional filter: string | string[]

    Returns boolean

Static defineLocale

Static getLocale

  • getLocale(): string

Static getMessage

  • getMessage(rule: string, type?: string | null): string | MessageCreator

Static getMessages

Static getNormalizer

Static getRule

Static hasLocale

  • hasLocale(locale: string): boolean

Static hasNormalizer

  • hasNormalizer(name: string): boolean

Static hasRule

  • hasRule(rule: string): boolean

Static isValidParams

  • isValidParams(value: any): boolean

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static registerAsyncRule

Static registerNormalizer

Static registerRule

Static setLocale

  • setLocale(locale: string): void

Static setMessage

  • setMessage(rule: string, message: Message): void

Static setMessages

Generated using TypeDoc