Source of file CharacterValidator.php

Size: 1,291 Bytes - Last Modified: 2016-05-18T03:08:27+02:00

buildproject/core/module_system/system/validators/CharacterValidator.php

1234567891011121314151617181920212223242526272829303132333435363738394041
<?php
/*"******************************************************************************************************
*   (c) 2007-2016 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id$                                   *
********************************************************************************************************/

namespace Kajona\System\System\Validators;

use Kajona\System\System\ValidatorInterface;


/**
 * A simple validator to validate if a value is a single caracter.
 * By default, the string must contain a single char, the max length is unlimited.
 *
 * @author sidler@mulchprod.de
 * @since 4.0
 * @package module_system
 */
class CharacterValidator implements ValidatorInterface {

    /**
     * Validates the passed chunk of data.
     * In most cases, this'll be a string-object.
     *
     * @param string $objValue
     * @return bool
     */
    public function validate($objValue) {

        if(is_string($objValue) && uniStrlen($objValue) == 1)
            return true;

        return false;
    }


}