Class

VPValidator

VPValidator()

VPValidator Instance

Constructor

# new VPValidator()

Validator instances are responsible for managing fieldsets. Validator instances are capable of dispatching validation on all fieldsets (and fields), allowing for a single "isValid" check.

View Source Validator.ts, line 21

Example
<form id="sample_form">
  ...
</form>

const Validator = new VP.Validator(
 document.getElementById('sample_form'), <options>);

Extends

Classes

VPValidator

Methods

# addEventListener(event_name, callback)

Add an event listener

Parameters:
Name Type Description
event_name string

Name of the event

callback EventCallback

Event callback to fire

Overrides:

View Source mixins/EventEmitter.ts, line 22

# addFieldset(fieldset, indexopt)

Add a fieldset instance to be tracked

Parameters:
Name Type Attributes Description
fieldset VPFieldset

Fieldset to track

index number <optional>

Indicate the fieldset order to track by

View Source Validator.ts, line 166

# addMessage(message, statusopt)

Adds a unique message to the $MessageNode

Parameters:
Name Type Attributes Description
message

The message to append

status <optional>

An optional class to append indicating message status

Overrides:

View Source lib/DOMMessaging.ts, line 104

If the $MessageNode isn't set or isn't an HTMLElement

# addMessages(messages, statusopt)

Batch append messages

Parameters:
Name Type Attributes Description
messages

The messages to append

status <optional>

An optional class to append indicating message status

Overrides:

View Source lib/DOMMessaging.ts, line 125

If the $MessageNode isn't set or isn't an HTMLElement

# clearMessages()

Clear all messages from the $MessageNode (If set)

Overrides:

View Source lib/DOMMessaging.ts, line 146

# createEvent(event_name, options) → {Event}

Helper for creating a new event, supporting IE9

Parameters:
Name Type Description
event_name string

Name of the event

options EventOptions

Event options

Overrides:

View Source mixins/EventEmitter.ts, line 70

Event

# createFieldset(el, options, fieldsopt)

Helper method for creating a new Fieldset to automatically track

Parameters:
Name Type Attributes Description
el HTMLElement

Fieldset element

options VPFieldsetOptions

Options to apply to the fieldset instance

fields Array.<VPField> <optional>

Fields to append to the fieldset

View Source Validator.ts, line 191

# dispatchEvent(event, data) → {boolean}

Include support for passing data along event

Parameters:
Name Type Description
event Event

the Event object to dispatch

data any

Data to be passed to the callback

Overrides:

View Source mixins/EventEmitter.ts, line 52

boolean

# findFieldsets(fieldsetOptionsopt)

Helper for automatically parsing child elements for Fieldsets

Parameters:
Name Type Attributes Description
fieldsetOptions VPFieldsetOptions | Array.<VPFieldsetOptions> <optional>

Options to apply to the found fieldsets. If array, options will apply based on index

View Source Validator.ts, line 201

# generateMessageNode(anchoropt, posopt)

Generate a messageNode where messages can be added and removed in a managed way.

Parameters:
Name Type Attributes Description
anchor <optional>

The anchor to use for the $MessageNode (Defaults to $MessageAnchor)

pos <optional>

The position to set $MessageNode inside the $MessageAnchor

Overrides:

View Source lib/DOMMessaging.ts, line 68

If anchor isn't an Element

If pos isn't a valid

VerticalPosition

# isElementVisible(element)

Helper method to determine if the element is visible within the DOM

Parameters:
Name Type Description
element HTMLElement

Element to test

Overrides:

View Source Validatable.ts, line 149

boolean

# isValid()

IsValid is a standard method for validating the internal state of a validator and all it's associated fieldsets (and fields). This method supports dynamic checks for determining if validation should be performed async or sync.

If any custom validation rules resolve async, validation will be performed async. Otherwise, all validation is performed synchronously. Optionally, You may enforce async validation through a validation option. This will enforce all validation is returned as a promise.

Further, this validation library is capable of short-circuit validation. Lazy validation will stop validation on the first instance of an error.

See:

View Source Validator.ts, line 90

# removeEventListener(event_name, callback) → {EventCallback|null}

Remove an event listener

Parameters:
Name Type Description
event_name string

Name of the event

callback EventCallback

The event callback to remove

Overrides:

View Source mixins/EventEmitter.ts, line 34

EventCallback | null

# removeFieldset(fieldset)

Remove a tracked fieldset from this validator

Parameters:
Name Type Description
fieldset VPFieldset

Fieldset instance to remove

View Source Validator.ts, line 173

# removeMessage(message)

Remove a message

Parameters:
Name Type Description
message

The message to remove

Overrides:

View Source lib/DOMMessaging.ts, line 135

If the $MessageNode isn't set or isn't an HTMLElement

# removeMessageNode()

Removes the $MessageNode from the $MessageAnchor

Overrides:

View Source lib/DOMMessaging.ts, line 92

If the $MessageNode isn't set or isn't an HTMLElement

# scrollTo()

Scroll to the tracked element

Overrides:

View Source Validatable.ts, line 86