ColdBox Platform v3.8.0

coldbox.system.validation.result
Class ValidationResult

WEB-INF.cftags.component
        extended by coldbox.system.validation.result.ValidationResult
All Implemented Interfaces:
IValidationResult

public class ValidationResult
extends WEB-INF.cftags.component
Property Summary
Type Property & Description Default Serializable Required
 struct constraints
          The constraints evaluated in the validation process

Attributes:
true false
 array errors
          A collection of error objects represented in this result object

Attributes:
true false
 string locale
          The locale this result validation is using

Attributes:
true false
 any resourceBundle
          The resource bundle object

Attributes:
true false
 struct resultMetadata
          Extra metadata you can store in the results object

Attributes:
true false
 string targetName
          The name of the target object

Attributes:
true false
 
Constructor Summary
init([string locale=''], [string targetName=''], [any resourceBundle=''], [struct constraints='[runtime expression]'])
 
Method Summary
 struct GETCONSTRAINTS()
          get: The constraints evaluated in the validation process
 array GETERRORS()
          get: A collection of error objects represented in this result object
 string GETLOCALE()
          get: The locale this result validation is using
 any GETRESOURCEBUNDLE()
          get: The resource bundle object
 ValidationResult SETCONSTRAINTS(struct constraints)
          set: The constraints evaluated in the validation process
 ValidationResult SETERRORS(array errors)
          set: A collection of error objects represented in this result object
 ValidationResult SETRESOURCEBUNDLE(any resourceBundle)
          set: The resource bundle object
 IValidationResult addError(IValidationError error)
          Add errors into the result object
 IValidationResult clearErrors()
          Clear All errors
 array getAllErrors([string field])
          Get the Errors Array, which is an array of error messages (strings)
 string getAllErrorsAsJSON([string field])
          Get all errors or by field as a JSON structure
 struct getAllErrorsAsStruct([string field])
          Get all errors as flat structure that can easily be used for UI display
 numeric getErrorCount([string field])
          Get how many errors you have
 coldbox.system.validation.result.IValidationError[] getFieldErrors(string field)
          Get an error object for a specific field that failed
 struct getResultMetadata()
          Get a collection of metadata about the validation results
 string getTargetName()
          Get the name of the target object that got validated
 string getValidationLocale()
          Get the validation locale
private void globalReplacements(any message, any error)
 boolean hasErrors([string field])
          Determine if the results had error or not
 boolean hasLocale()
          has locale information
 IValidationError newError([struct properties])
          Get a new error object
 IValidationResult setLocale(string locale)
          Set the validation locale
 IValidationResult setResultMetadata(struct data)
          Set a collection of metadata into the results object
 IValidationResult setTargetName(string name)
          Set the validation target object name
 
Methods inherited from class WEB-INF.cftags.component
None
 

Constructor Detail

init

public init([string locale=''], [string targetName=''], [any resourceBundle=''], [struct constraints='[runtime expression]'])

Parameters:
locale
targetName
resourceBundle
constraints
Property Detail

constraints

struct constraints
The constraints evaluated in the validation process

Attributes:
default -
serializable - true
required - false

errors

array errors
A collection of error objects represented in this result object

Attributes:
default -
serializable - true
required - false

locale

string locale
The locale this result validation is using

Attributes:
default -
serializable - true
required - false

resourceBundle

any resourceBundle
The resource bundle object

Attributes:
default -
serializable - true
required - false

resultMetadata

struct resultMetadata
Extra metadata you can store in the results object

Attributes:
default -
serializable - true
required - false

targetName

string targetName
The name of the target object

Attributes:
default -
serializable - true
required - false

Method Detail

GETCONSTRAINTS

public struct GETCONSTRAINTS()
get: The constraints evaluated in the validation process


GETERRORS

public array GETERRORS()
get: A collection of error objects represented in this result object


GETLOCALE

public string GETLOCALE()
get: The locale this result validation is using


GETRESOURCEBUNDLE

public any GETRESOURCEBUNDLE()
get: The resource bundle object


SETCONSTRAINTS

public ValidationResult SETCONSTRAINTS(struct constraints)
set: The constraints evaluated in the validation process

Parameters:
constraints

SETERRORS

public ValidationResult SETERRORS(array errors)
set: A collection of error objects represented in this result object

Parameters:
errors

SETRESOURCEBUNDLE

public ValidationResult SETRESOURCEBUNDLE(any resourceBundle)
set: The resource bundle object

Parameters:
resourceBundle

addError

public IValidationResult addError(IValidationError error)
Add errors into the result object

Specified by:
addError in interface IValidationResult
Parameters:
error - The validation error to add into the results object

clearErrors

public IValidationResult clearErrors()
Clear All errors

Specified by:
clearErrors in interface IValidationResult

getAllErrors

public array getAllErrors([string field])
Get the Errors Array, which is an array of error messages (strings)

Specified by:
getAllErrors in interface IValidationResult
Parameters:
field - The field to use to filter the error messages on (optional)

getAllErrorsAsJSON

public string getAllErrorsAsJSON([string field])
Get all errors or by field as a JSON structure

Parameters:
field

getAllErrorsAsStruct

public struct getAllErrorsAsStruct([string field])
Get all errors as flat structure that can easily be used for UI display

Parameters:
field

getErrorCount

public numeric getErrorCount([string field])
Get how many errors you have

Specified by:
getErrorCount in interface IValidationResult
Parameters:
field - The field to count on (optional)

getFieldErrors

public coldbox.system.validation.result.IValidationError[] getFieldErrors(string field)
Get an error object for a specific field that failed. Throws exception if the field does not exist

Specified by:
getFieldErrors in interface IValidationResult
Parameters:
field - The field to return error objects on

getResultMetadata

public struct getResultMetadata()
Get a collection of metadata about the validation results

Specified by:
getResultMetadata in interface IValidationResult

getTargetName

public string getTargetName()
Get the name of the target object that got validated

Specified by:
getTargetName in interface IValidationResult

getValidationLocale

public string getValidationLocale()
Get the validation locale

Specified by:
getValidationLocale in interface IValidationResult

globalReplacements

private void globalReplacements(any message, any error)

Parameters:
message
error

hasErrors

public boolean hasErrors([string field])
Determine if the results had error or not

Specified by:
hasErrors in interface IValidationResult
Parameters:
field - The field to count on (optional)

hasLocale

public boolean hasLocale()
has locale information

Specified by:
hasLocale in interface IValidationResult

newError

public IValidationError newError([struct properties])
Get a new error object

Parameters:
properties

setLocale

public IValidationResult setLocale(string locale)
Set the validation locale

Specified by:
setLocale in interface IValidationResult
Parameters:
locale

setResultMetadata

public IValidationResult setResultMetadata(struct data)
Set a collection of metadata into the results object

Specified by:
setResultMetadata in interface IValidationResult
Parameters:
data

setTargetName

public IValidationResult setTargetName(string name)
Set the validation target object name

Specified by:
setTargetName in interface IValidationResult
Parameters:
name

ColdBox Platform v3.8.0