ColdBox Platform v3.8.0

coldbox.system.validation
Class ValidationManager

WEB-INF.cftags.component
        extended by coldbox.system.validation.ValidationManager
All Implemented Interfaces:
IValidationManager

public class ValidationManager
extends WEB-INF.cftags.component
Property Summary
Type Property & Description Default Serializable Required
 any resourceBundle
          A resource bundle plugin for i18n capabilities

Attributes:
  • inject = coldbox:plugin:ResourceBundle
true false
 struct sharedConstraints
          Shared constraints that can be loaded into the validation manager

Attributes:
true false
 any wirebox
          WireBox Object Factory

Attributes:
  • inject = wirebox
true false
 
Constructor Summary
init([struct sharedConstraints='[runtime expression]'])
          Constructor
 
Method Summary
 any GETRESOURCEBUNDLE()
          get: A resource bundle plugin for i18n capabilities
 any GETWIREBOX()
          get: WireBox Object Factory
 ValidationManager SETRESOURCEBUNDLE(any resourceBundle)
          set: A resource bundle plugin for i18n capabilities
 ValidationManager SETWIREBOX(any wirebox)
          set: WireBox Object Factory
 IValidationManager addSharedConstraint(string name, struct constraint)
          Store a shared constraint
private struct determineConstraintsDefinition(any target, [any constraints=''])
          Determine from where to take the constraints from
private struct discoverConstraints(any target)
          Get the constraints structure from target objects, if none, it returns an empty structure
 struct getSharedConstraints([string name])
          Retrieve the shared constraints, all of them or by name
 IValidator getValidator(string validatorType, any validationData)
          Create validators according to types and validation data
 ValidationManager processRules(IValidationResult results, struct rules, any target, any field)
          Process validation rules on a target object and field
 IValidationManager setSharedConstraints([struct constraints])
          Set the entire shared constraints structure
 boolean sharedConstraintsExists(string name)
          Check if a shared constraint exists by name
 coldbox.system.validation.IValidationResult validate(any target, [string fields='*'], [any constraints=''], [string locale=''], [string excludeFields=''])
          Validate an object
 
Methods inherited from class WEB-INF.cftags.component
None
 

Constructor Detail

init

public init([struct sharedConstraints='[runtime expression]'])
Constructor

Parameters:
sharedConstraints - A structure of shared constraints
Property Detail

resourceBundle

any resourceBundle
A resource bundle plugin for i18n capabilities

Attributes:
inject - coldbox:plugin:ResourceBundle
required - false
serializable - true
default -

sharedConstraints

struct sharedConstraints
Shared constraints that can be loaded into the validation manager

Attributes:
default -
serializable - true
required - false

wirebox

any wirebox
WireBox Object Factory

Attributes:
inject - wirebox
required - false
serializable - true
default -

Method Detail

GETRESOURCEBUNDLE

public any GETRESOURCEBUNDLE()
get: A resource bundle plugin for i18n capabilities


GETWIREBOX

public any GETWIREBOX()
get: WireBox Object Factory


SETRESOURCEBUNDLE

public ValidationManager SETRESOURCEBUNDLE(any resourceBundle)
set: A resource bundle plugin for i18n capabilities

Parameters:
resourceBundle

SETWIREBOX

public ValidationManager SETWIREBOX(any wirebox)
set: WireBox Object Factory

Parameters:
wirebox

addSharedConstraint

public IValidationManager addSharedConstraint(string name, struct constraint)
Store a shared constraint

Specified by:
addSharedConstraint in interface IValidationManager
Parameters:
name - Filter by name or not
constraint - The constraint to store.

determineConstraintsDefinition

private struct determineConstraintsDefinition(any target, [any constraints=''])
Determine from where to take the constraints from

Parameters:
target
constraints

discoverConstraints

private struct discoverConstraints(any target)
Get the constraints structure from target objects, if none, it returns an empty structure

Parameters:
target

getSharedConstraints

public struct getSharedConstraints([string name])
Retrieve the shared constraints, all of them or by name

Specified by:
getSharedConstraints in interface IValidationManager
Parameters:
name - Filter by name or not

getValidator

public IValidator getValidator(string validatorType, any validationData)
Create validators according to types and validation data

Parameters:
validatorType
validationData

processRules

public ValidationManager processRules(IValidationResult results, struct rules, any target, any field)
Process validation rules on a target object and field

Parameters:
results
rules
target
field

setSharedConstraints

public IValidationManager setSharedConstraints([struct constraints])
Set the entire shared constraints structure

Specified by:
setSharedConstraints in interface IValidationManager
Parameters:
constraints - Filter by name or not

sharedConstraintsExists

public boolean sharedConstraintsExists(string name)
Check if a shared constraint exists by name

Specified by:
sharedConstraintsExists in interface IValidationManager
Parameters:
name - The shared constraint to check

validate

public coldbox.system.validation.IValidationResult validate(any target, [string fields='*'], [any constraints=''], [string locale=''], [string excludeFields=''])
Validate an object

Specified by:
validate in interface IValidationManager
Parameters:
target - The target object to validate or a structure like a form or collection. If it is a collection, we will build a generic object for you so we can validate the structure of name-value pairs.
fields - One or more fields to validate on, by default it validates all fields in the constraints. This can be a simple list or an array.
constraints - An optional shared constraints name or an actual structure of constraints to validate on.
locale - An optional locale to use for i18n messages
excludeFields - An optional list of fields to exclude from the validation.

ColdBox Platform v3.8.0