Home Reference Source
import JediValidate from 'jedi-validate/src/jedi-validate.js'
public class | source

JediValidate

JediValidate - validation

Constructor Summary

Public Constructor
public

constructor(root: HTMLElement, options: object)

JediValidate

Member Summary

Private Members
private

Object with error message

private

Translation dictionary

private

Object with error message

private

fields: Object<string, Element>

Object with fields

private

handleSubmit(event: Event): *

Handle form submit

private

inputs: Object<string, HTMLInputElement|HTMLSelectElement|Array>

Object with inputs nodes

private

messages: Object<string, Element>

Object with message nodes

private

methods: Object<string, {func: Function, message: string}>

Validate methods

private

Elements

private

options: {ajax: {url: string, enctype: string, sendType: string, method: string}, rules: {}, messages: {}, containers: {parent: string, message: string, baseMessage: string}, states: {error: string, valid: string, pristine: string, dirty: string}, formStatePrefix: string, callbacks: {success: function, error: function}, clean: boolean, redirect: boolean, language: string, translations: {}}

Validator options

private

root: Element

Root element

private

Validator rules

private

translate(text: string): *

Translate

Method Summary

Public Methods
public

addMethod(rule: string, func: Function, message: string)

Add rule to validator

public

addToDictionary(sourceText: string, translatedText: string, language: string)

Add localization to JediValidate

public

Collect data

Private Methods
private

Handle input change

private

Handle input

private

ready()

Ready

private

send(options: object)

Send form

Public Constructors

public constructor(root: HTMLElement, options: object) source

JediValidate

Params:

NameTypeAttributeDescription
root HTMLElement

element which wraps form element

options object

object with options

Private Members

private data: object source

Object with error message

private dictionary: Dictionary source

Translation dictionary

private errorMessages: Object<string, Object<string, string>> source

Object with error message

private fields: Object<string, Element> source

Object with fields

private handleSubmit(event: Event): * source

Handle form submit

private inputs: Object<string, HTMLInputElement|HTMLSelectElement|Array> source

Object with inputs nodes

private messages: Object<string, Element> source

Object with message nodes

private methods: Object<string, {func: Function, message: string}> source

Validate methods

private nodes: object source

Elements

private options: {ajax: {url: string, enctype: string, sendType: string, method: string}, rules: {}, messages: {}, containers: {parent: string, message: string, baseMessage: string}, states: {error: string, valid: string, pristine: string, dirty: string}, formStatePrefix: string, callbacks: {success: function, error: function}, clean: boolean, redirect: boolean, language: string, translations: {}} source

Validator options

private root: Element source

Root element

private rules: object source

Validator rules

private translate(text: string): * source

Translate

Public Methods

public addMethod(rule: string, func: Function, message: string) source

Add rule to validator

Params:

NameTypeAttributeDescription
rule string

rule name

func Function

function

message string

error message

public addToDictionary(sourceText: string, translatedText: string, language: string) source

Add localization to JediValidate

Params:

NameTypeAttributeDescription
sourceText string

text on english

translatedText string

text on needed language

language string

language

public collect(params: string | Array<string>): Object source

Collect data

Params:

NameTypeAttributeDescription
params string | Array<string>

field

Return:

Object

Private Methods

private handleInputChange(name: string) source

Handle input change

Params:

NameTypeAttributeDescription
name string

private handleInputInput(name: string) source

Handle input

Params:

NameTypeAttributeDescription
name string

private ready() source

Ready

private send(options: object) source

Send form

Params:

NameTypeAttributeDescription
options object

object with options for sending

options.url string
options.enctype string
options.sendType string
options.method string
options.data string | FormData