src/Common/Model/Base.php
protected function describeFieldsGuessValidation(&$oField, $sType)
    {
        preg_match('/^(.*?)(\((.+?)\)(.*))?$/', $sType, $aMatches);

        $sType   = ArrayHelper::getFromArray(1, $aMatches, 'text');
        $iLength = ArrayHelper::getFromArray(3, $aMatches);
        $sExtra  = trim(strtolower(ArrayHelper::getFromArray(4, $aMatches)));

        switch ($sType) {

            /**
             * Numeric
             */
            case 'int':
                if ($sExtra === 'unsigned') {
                    $oField->validation[] = 'greater_than[-1]';
                } else {
                    $oField->validation[] = 'integer';
                }
                break;

            case 'tinyint':
                if ($oField->type === 'boolean') {
                    $oField->validation[] = 'is_bool';
                } else {
                    $oField->validation[] = 'integer';
                }
                break;

            /**
             * String
             */
            case 'varchar':
                if ($iLength) {
                    $oField->validation[] = 'max_length[' . $iLength . ']';
                }
                break;

            /**
             * Date and time
             */
            case 'date':
                $oField->validation[] = 'valid_date';
                break;
            case 'datetime':
                $oField->validation[] = 'valid_datetime';
                break;

            /**
             * ENUM
             */
            case 'enum':
                $oField->validation[] = 'in_list[' . implode(',', array_keys($oField->options)) . ']';
                break;

            /**
             * Default to basic string
             */
            default:
                if ($iLength) {
                    $oField->validation[] = 'max_length[' . $iLength . ']';
                }
                break;
        }
    }
protected function describeFieldsGuessValidation(&$oField, $sType)
    {
        preg_match('/^(.*?)(\((.+?)\)(.*))?$/', $sType, $aMatches);

        $sType   = ArrayHelper::getFromArray(1, $aMatches, 'text');
        $iLength = ArrayHelper::getFromArray(3, $aMatches);
        $sExtra  = trim(strtolower(ArrayHelper::getFromArray(4, $aMatches)));

        switch ($sType) {

            /**
             * Numeric
             */
            case 'int':
                if ($sExtra === 'unsigned') {
                    $oField->validation[] = 'greater_than[-1]';
                } else {
                    $oField->validation[] = 'integer';
                }
                break;

            case 'tinyint':
                if ($oField->type === 'boolean') {
                    $oField->validation[] = 'is_bool';
                } else {
                    $oField->validation[] = 'integer';
                }
                break;

            /**
             * String
             */
            case 'varchar':
                if ($iLength) {
                    $oField->validation[] = 'max_length[' . $iLength . ']';
                }
                break;

            /**
             * Date and time
             */
            case 'date':
                $oField->validation[] = 'valid_date';
                break;
            case 'datetime':
                $oField->validation[] = 'valid_datetime';
                break;

            /**
             * ENUM
             */
            case 'enum':
                $oField->validation[] = 'in_list[' . implode(',', array_keys($oField->options)) . ']';
                break;

            /**
             * Default to basic string
             */
            default:
                if ($iLength) {
                    $oField->validation[] = 'max_length[' . $iLength . ']';
                }
                break;
        }
    }
protected function describeFieldsGuessValidation ( & $ oField , $ sType ) { preg_match ( '/^(.*?)(\((.+?)\)(.*))?$/' , $ sType , $ aMatches ) ; $ sType = ArrayHelper :: getFromArray ( 1 , $ aMatches , 'text' ) ; $ iLength = ArrayHelper :: getFromArray ( 3 , $ aMatches ) ; $ sExtra = trim ( strtolower ( ArrayHelper :: getFromArray ( 4 , $ aMatches ) ) ) ; switch ( $ sType ) { /**
             * Numeric
             */ case 'int' : if ( $ sExtra === 'unsigned' ) { $ oField -> validation [ ] = 'greater_than[-1]' ; } else { $ oField -> validation [ ] = 'integer' ; } break ; case 'tinyint' : if ( $ oField -> type === 'boolean' ) { $ oField -> validation [ ] = 'is_bool' ; } else { $ oField -> validation [ ] = 'integer' ; } break ; /**
             * String
             */ case 'varchar' : if ( $ iLength ) { $ oField -> validation [ ] = 'max_length[' . $ iLength . ']' ; } break ; /**
             * Date and time
             */ case 'date' : $ oField -> validation [ ] = 'valid_date' ; break ; case 'datetime' : $ oField -> validation [ ] = 'valid_datetime' ; break ; /**
             * ENUM
             */ case 'enum' : $ oField -> validation [ ] = 'in_list[' . implode ( ',' , array_keys ( $ oField -> options ) ) . ']' ; break ; /**
             * Default to basic string
             */ default : if ( $ iLength ) { $ oField -> validation [ ] = 'max_length[' . $ iLength . ']' ; } break ; } }
Guesses the field's validation rules based on it's type

@param \stdClass $oField The field object
@param string    $sType  The database type
Guesses the field s validation rules based on it s type