contentbox.modules.contentbox-deps.modules.cborm.modules.cbvalidation.models

Class ValidationManager

lucee.Component
    extended by contentbox.modules.contentbox-deps.modules.cborm.modules.cbvalidation.models.ValidationManager
All Implemented Interfaces:
IValidationManager
Class Attributes:
  • serialize : false
  •  
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any resourceService
          A resource bundle plugin for i18n capabilities.

    • access = public
    • returntype = any
    • inject = ResourceService@cbi18n
    true false
    struct sharedConstraints
          Shared constraints that can be loaded into the validation manager.

    • access = public
    • returntype = any
    true false
    any wirebox
          WireBox Object Factory.

    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init([struct sharedConstraints='[runtime expression]'])
          Constructor.
    Method Summary
    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.
    string getResourceService()
    struct getSharedConstraints([string name])
         Retrieve the shared constraints, all of them or by name.
    cbvalidation.models.validators.IValidator getValidator(string validatorType, any validationData)
         Create validators according to types and validation data.
    string getWirebox()
    ValidationManager processRules(cbvalidation.models.result.ivalidationresult results, struct rules, any target, any field)
         Process validation rules on a target object and field.
    any setResourceService(any resourceService)
    IValidationManager setSharedConstraints([struct constraints])
         Set the entire shared constraints structure.
    any setWirebox(any wirebox)
    boolean sharedConstraintsExists(string name)
         Check if a shared constraint exists by name.
    contentbox.modules.contentbox-deps.modules.cborm.modules.cbvalidation.models.IValidationResult validate(any target, [string fields='*'], [any constraints=''], [string locale=''], [string excludeFields=''], [string includeFields=''])
         Validate an object using constraints.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

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

    Constructor

    Parameters:
    sharedConstraints - A structure of shared constraints

    Property Detail

    resourceService

    property any resourceService

    A resource bundle plugin for i18n capabilities

    Attributes:
    access - public
    required - false
    returntype - any
    inject - ResourceService@cbi18n
    serializable - true

    sharedConstraints

    property struct sharedConstraints

    Shared constraints that can be loaded into the validation manager

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    wirebox

    property any wirebox

    WireBox Object Factory

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    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 - The target object
    constraints - The constraints rules
    Throws:
    ValidationManager.InvalidSharedConstraint

    discoverConstraints

    private struct discoverConstraints(any target)

    Get the constraints structure from target objects, if none, it returns an empty structure

    Parameters:
    target - The target object

    getResourceService

    public string getResourceService()


    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 cbvalidation.models.validators.IValidator getValidator(string validatorType, any validationData)

    Create validators according to types and validation data

    Parameters:
    validatorType - The type of validator to retrieve, either internal or class path or wirebox ID
    validationData - The validation data that is used for custom validators
    Throws:
    ValidationManager.InvalidValidatorType

    getWirebox

    public string getWirebox()


    processRules

    public ValidationManager processRules(cbvalidation.models.result.ivalidationresult results, struct rules, any target, any field)

    Process validation rules on a target object and field

    Parameters:
    results - The validation result object
    rules - The structure containing validation rules
    target - The target object to do validation on
    field - The field to validate

    setResourceService

    public any setResourceService(any resourceService)

    Parameters:
    resourceService

    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

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    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 contentbox.modules.contentbox-deps.modules.cborm.modules.cbvalidation.models.IValidationResult validate(any target, [string fields='*'], [any constraints=''], [string locale=''], [string excludeFields=''], [string includeFields=''])

    Validate an object using constraints

    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.
    includeFields - An optional list of fields to include in the validation.