Validate the user's entry

@param  mixed     $mInput The form input's value
@param  \stdClass $oField The complete field object

@throws FieldTypeException
@return boolean|string   boolean true if valid, string with error if invalid
976020
public function validate($mInput, $oField)
    {
        $mInput = parent::validate($mInput, $oField);

        if (!is_numeric($mInput)) {
            throw new FieldTypeException('This field should be numeric.', 1);
        }

        return $mInput;
    }
847101
protected function validate_min_age($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        $cdate1 = new DateTime(date('Y-m-d', strtotime($input[$field])));
        $today = new DateTime(date('d-m-Y'));

        $interval = $cdate1->diff($today);
        $age = $interval->y;

        if ($age <= $param) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
694057
public function validate($mInput, $oField)
    {
        $mInput = parent::validate($mInput, $oField);

        try {

            $oDate = new \DateTime($mInput);

            if (empty($oDate)) {
                throw new FieldTypeException('This field should be a valid date and time.', 1);
            }

        } catch (\Exception $e) {
            throw new FieldTypeException('This field should be a valid date and time.', 1);
        }

        return empty($oDate) ? null : $oDate->format('Y-m-d H:i:s');
    }
324872
public function validate($mInput, $oField)
    {
        //  Test for required fields
        if (!empty($oField->is_required) && empty($mInput)) {
            throw new FieldTypeExceptionRequired('This field is required.', 1);
        }

        //  If the field accepts options then ensure that the value is a valid option for the field
        if (static::SUPPORTS_OPTIONS) {

            $aValidValues = [];

            foreach ($oField->options->data as $oOption) {
                $aValidValues[] = $oOption->id;
            }

            /**
             * Cast the field to an array so that fields which accept multiple values
             * (e.g checkboxes) validate in the same way.
             */

            $aInput = (array) $mInput;

            foreach ($aInput as $sInput) {
                if (!in_array($sInput, $aValidValues)) {
                    throw new FieldTypeExceptionInvalidOption('Please choose a valid option.', 1);
                }
            }
        }

        return $mInput;
    }
297751
public function validate($field, $input, array $params = array())
    {
        try {
            if ($input == '' || empty($params['0'])) {
                return false;
            }
            
            $params = $params['0'];
            if (empty($params['dropbox_access_token']) || empty($params['dropbox_app_secret'])) {
                return false;
            }
            
            $client = m62Dropbox::getRemoteClient($params['dropbox_access_token'], $params['dropbox_app_secret']);
            $adapter = new m62Dropbox($client);
            
            $filesystem = new Remote($adapter);
            if (! $filesystem->getAdapter()->listContents()) {
                return false;
            }
            
            return true;
        } catch (\Exception $e) {
            
            $this->setErrorMessage($e->getMessage());
            return false;
        }
    }
1025190
public function validate( $input )
    {
        // We expect an array of documents, and if this isn't an array, we can
        // bail out immediately.
        if ( !is_array( $input ) )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // Reuse the document validator to validate the single documents in the
        // array.
        foreach ( $input as $key => $value )
        {
            $input[$key] = parent::validate( $value );
        }

        // If no exception has been thrown during the process, return the valid
        // array
        return $input;
    }
1372367
public function validateRange($min_amount, $max_amount)
    {
        $this->validator_attributes[] = 'data-parsley-range="[' . (float)$min_amount . ', ' . (float)$max_amount . ']"';

        $this->validator_checks['min'] = (float)$min_amount;
        $this->validator_checks['max'] = (float)$max_amount;

        return $this;
    }
81519
public function validateLength($min_length, $max_length)
    {
        $this->validator_attributes[] = 'data-parsley-length="[' . (int)$min_length . ', ' . (int)$max_length . ']"';

        $this->validator_checks['min_length'] = (int)$min_length;
        $this->validator_checks['max_length'] = (int)$max_length;

        return $this;
    }
136561
public function ValidateUserInput()
    {
        $bIsValid = parent::ValidateUserInput();

        if ($bIsValid) {
            $oMsgManager = TCMSMessageManager::GetInstance();

            $aDefaultVals = $this->GetDefaultUserPaymentData();

            foreach (array_keys($aDefaultVals) as $sField) {
                if (!array_key_exists($sField, $this->aPaymentUserData) || empty($this->aPaymentUserData[$sField])) {
                    $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-'.$sField, 'ERROR-USER-REQUIRED-FIELD-MISSING');
                    $bIsValid = false;
                }
            }
        }

        return $bIsValid;
    }
1253014
public function whereBetween($field, $min, $max)
    {
        if ($min === null || $min === '') {
            return $max === null || $max === '' ? $this : $this->whereCmp($field, '<=', $max);
        } elseif ($max === null || $max === '') {
            return $min === null || $min === '' ? $this : $this->whereCmp($field, '>=', $min);
        }

        $this->_filters[] = [$field => ['$gte' => $this->normalizeValue($field, $min), '$lte' => $this->normalizeValue($field, $max)]];

        return $this;
    }
991300
public function validate( $input )
    {
        // Check if passed input is an object and instance of phpillowDocument
        // at all, otherwise we can exit immediately
        if ( !is_object( $input ) ||
             !( $input instanceof phpillowDocument ) )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // If a specific document class is required, check this type is passed,
        // otherwise throw an exception.
        if ( ( $this->documentClass !== false ) &&
             !( $input instanceof $this->documentClass ) )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // Check if the document already has an ID assigned, otherwise it has
        // not yet been stored in the database and though is invalid.
        if ( $input->_id === null )
        {
            throw new phpillowValidationException( 'Invalid document type provided.', array() );
        }

        // If all above checks has been passed just return the document ID,
        // because that is all we need to store in database.
        return $input->_id;
    }
1214030
private static function validateRange($value, $min, $max)
	    {
	        $res = filter_var($value, FILTER_VALIDATE_INT, array(
	            'options' => array('min_range' => $min, 'max_range' => $max)
	        ));
	        if (false === $res) {
	            throw new OutOfRangeException("the submitted value is not contained within the valid range");
	        }

	        return $res;
	    }
80485
public function ValidateUserInput()
    {
        $bIsValid = parent::ValidateUserInput();

        if ($bIsValid) {
            $oMsgManager = TCMSMessageManager::GetInstance();

            $sField = 'pseudocardpan';
            if (!array_key_exists($sField, $this->aPaymentUserData) || empty($this->aPaymentUserData[$sField])) {
                $oMsgManager->AddMessage(self::MSG_MANAGER_NAME.'-'.$sField, 'ERROR-USER-REQUIRED-FIELD-MISSING');
                $bIsValid = false;
            }
        }

        return $bIsValid;
    }
1055352
public static function check(Validator $validator, $minLimit = 0, $maxLimit = 1200)
    {
        $formData = $validator->getData();

        // Check post values
        if (!isset($formData['_captcha']) || !($token = self::getToken($formData['_captcha']))) {
            return false;
        }

        // Hidden "must be empty" field check
        if (!array_key_exists($token['must_be_empty'], $formData) || !empty($formData[$token['must_be_empty']])) {
            return false;
        }

        // Check time limits
        $now = time();
        if ($now - $token['timestamp'] < $minLimit || $now - $token['timestamp'] > $maxLimit) {
            return false;
        }

        // Check the random posted field
        if (empty($formData[$token['random_field_name']])) {
            return false;
        }

        // Check if the random field value is similar to the token value
        $randomField = $formData[$token['random_field_name']];
        if (!ctype_digit($randomField) || $token['timestamp'] != $randomField) {
            return false;
        }

        // Everything is ok, return true
        return true;
    }
1323257
def _validate_min(self, min_value, field, value):
        
        try:
            if value < min_value:
                self._error(field, errors.MIN_VALUE)
        except TypeError:
            pass
623578
final public static function validateUserId (array $fields=[], string $field) : bool
	{
		$fieldsWithError 	= "";
		$field 				= static::checkGlobal($field);
		foreach ($fields as $fieldName => $format)
		{
			$value = static::setValueNull($field[$fieldName]);
			if ($value !== NULL)
			{
				if (!static::formatMatch($value, $format))
					$fieldsWithError .= "'".fieldNameAsText($fieldName)."', ";
			}
		}
		static::setError($fieldsWithError);
		return static::checkError();
	}
1009372
protected void validateField(int field) {
        int y;
        switch (field) {
        case DAY_OF_MONTH:
            y = handleGetExtendedYear();
            validateField(field, 1, handleGetMonthLength(y, internalGet(MONTH)));
            break;
        case DAY_OF_YEAR:
            y = handleGetExtendedYear();
            validateField(field, 1, handleGetYearLength(y));
            break;
        case DAY_OF_WEEK_IN_MONTH:
            if (internalGet(field) == 0) {
                throw new IllegalArgumentException("DAY_OF_WEEK_IN_MONTH cannot be zero");
            }
            validateField(field, getMinimum(field), getMaximum(field));
            break;
        default:
            validateField(field, getMinimum(field), getMaximum(field));
            break;
        }
    }