Class Validation

Helper functions to use with validating submitting forms.

Namespace: Concrete\Core\Form\Service
Package: Helpers\Validation
Copyright: Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org)
License: MIT License
Author: Andrew Embler andrew@concrete5.org
Located at src/Form/Service/Validation.php

Methods summary

public
public
# addUploadedImage( string $field, string $errorMsg = null, boolean $emptyIsOk = true )

Adds a test to a field to ensure that, if set, it is a valid uploaded image.

public
# addRequired( string $field, string $errorMsg = null, string $validate = Concrete\Core\Form\Service\Validation::VALID_NOT_EMPTY )

Adds a required field to the form helper object. This will then be typically used in conjunction with the test() method to see if the test is passed

public
# addUploadedFile( string $field, string $errorMsg = null, boolean $emptyIsOk = true )

Adds a test to a field to ensure that, if set, it is a valid uploaded file.

public
# addInteger( string $field, string $errorMsg = null, boolean $emptyIsOk = true )

Adds a required field and tests that it is integer only

public
# addRequiredToken( $value, $errorMsg = null )
public
# addRequiredEmail( string $field, string $errorMsg = null )

Adds a required email address to the suite of tests to be run.

public
# setFiles( )

Sets the data files array

public
# setData( array $data )

An associative array that we setup to validate against. Typical usage is $val->setData($_POST);

public
# invalidate( $message )
public integer
# test( )

After the validation error helper has been setup, the test() method ensures that all fields that require validation pass. Returns the number of invalid fields (0 = success)

protected
public Concrete\Core\Error\Error
# getError( )

Gets the error object.

if ($val->test() > 0) {
        $e = $val->getError();
    }

Constants summary

integer VALID_NOT_EMPTY
# 1
integer VALID_EMAIL
# 2
integer VALID_INTEGER
# 3
integer VALID_INTEGER_REQUIRED
# 4
integer VALID_UPLOADED_IMAGE
# 10
integer VALID_UPLOADED_IMAGE_REQUIRED
# 11
integer VALID_UPLOADED_FILE
# 20
integer VALID_UPLOADED_FILE_REQUIRED
# 25
integer VALID_TOKEN
# 30
integer VALID_FIELD_INVALID
# 99

Properties summary

protected array $fields
# array()
protected array $fieldsInvalid
# array()
protected array $data
# array()
protected array $files
# array()
protected $error
#