Home Identifier Source Repository
import Validator from 'piggy-module/src/Validator.js'
public class | source

Validator

Class to validate properties of a Vo

Static Method Summary

Static Public Methods
public static

checkProperty(property: String, value: any): true

Check a property value

public static

getRulesFor(property: String): Array

Get the list of validation rules

public static

hasRulesFor(property: String): Boolean

Is there any validation rule for a given property

public static

Is a property required?

public static

Is a property unique?

public static

needToCheckProperty(property: String, value: any): Array

Does a property need to be checked?

public static

validate(fct: any, value: any, args: Array, skipIfEmpty: Boolean): Boolean

Run a validator rules and get the result

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Method Summary

Public Methods
public

To know if the validation failed

public

Validate all the properties of the current Vo

Static Public Methods

public static checkProperty(property: String, value: any): true source

Check a property value

Params:

NameTypeAttributeDescription
property String

the property name

value any

the property value

Return:

true

public static getRulesFor(property: String): Array source

Get the list of validation rules

Params:

NameTypeAttributeDescription
property String

the property name

Return:

Array

public static hasRulesFor(property: String): Boolean source

Is there any validation rule for a given property

Params:

NameTypeAttributeDescription
property String

the property name

Return:

Boolean

public static isPropertyRequired(property: String): Boolean source

Is a property required?

Params:

NameTypeAttributeDescription
property String

the property name

Return:

Boolean

public static isPropertyUnique(property: String): Boolean source

Is a property unique?

Params:

NameTypeAttributeDescription
property String

the property name

Return:

Boolean

public static needToCheckProperty(property: String, value: any): Array source

Does a property need to be checked?

Params:

NameTypeAttributeDescription
property String

the property name

value any

the property value

Return:

Array

public static validate(fct: any, value: any, args: Array, skipIfEmpty: Boolean): Boolean source

Run a validator rules and get the result

Params:

NameTypeAttributeDescription
fct any

the validation function or validator string name

value any

the property value

args Array

the validation rule options

skipIfEmpty Boolean

skip to check if the property is empty

Return:

Boolean

Public Constructors

public constructor(vo: Vo) source

Params:

NameTypeAttributeDescription
vo Vo
  • nullable: true

a Vo to validate

Public Members

public errors: Object source

Public Methods

public hasError(): Boolean source

To know if the validation failed

Return:

Boolean

public validateVo(): Validator source

Validate all the properties of the current Vo

Return:

Validator