Convert time attribute to UTC time.
@param string $attribute
@param array $params
@param mixed $validator
177345
public function gmdate($attribute, $params, $validator)
    {
        if (isset($this->$attribute)) {
            $timestamp = strtotime($this->$attribute);
            $this->{$attribute . 'InUtc'} = gmdate('Y-m-d H:i:s', $timestamp);
        }
    }
41450
public function validateModelId($attribute, $params)
    {
        /** @var ActiveRecord $class */
        $class = Model::findIdentity($this->model_class);
        if ($class === null) {
            $this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
        } else {
            $model = $class->name;
            if ($model::find()->where(['id' => $this->entity_id]) === false) {
                $this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
            }
        }
    }
18027
void timestampFormat(DateFormat format, String... attributes) {
        convertWith(new DateToStringConverter(format), attributes);
        convertWith(new StringToTimestampConverter(format), attributes);
    }
1224796
public static function date(Validator $validator, $data, $pattern, $rule, $parameters)
    {
        $format = !empty($parameters[0]) ? $parameters[0] : 'Y-m-d';
        foreach (Validator::getValues($data, $pattern) as $attribute => $value) {
            if (null === $value || empty($value)) {
                continue;
            }
            $d = \DateTime::createFromFormat($format, $value);
            if ($d && $d->format($format) == $value) {
                continue;
            }

            $validator->addError($attribute, $rule, [':format' => $format]);
        }
    }
417443
public function behaviorValidator($attribute, $params)
    {
        $behavior = $params['behavior'];
        $validator = $params['validator'];
        unset($params['behavior']);
        unset($params['validator']);
        if (($behavior = $this->getBehavior($behavior)) !== null) {
            return $behavior->{$validator}($attribute, $params);
        }

        return true;
    }
794420
protected function validateDateFormat($field, $value, $params)
    {
        $parsed = \date_parse_from_format($params[0], $value);

        return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
    }
807326
public function validate($validator)
    {
        // Don't validate empty fields
        if (empty($this->rawValue)) {
            return true;
        }

        // We submitted a value, but it couldn't be parsed
        if (empty($this->value)) {
            $validator->validationError(
                $this->name,
                _t(
                    'SilverStripe\\Forms\\TimeField.VALIDATEFORMAT',
                    "Please enter a valid time format ({format})",
                    ['format' => $this->getTimeFormat()]
                )
            );
            return false;
        }
        return true;
    }
782044
public function validateConverterClass($attribute, $params)
    {
        $className = $this->$attribute;
        if (class_exists($className) === true) {
            if (new $className instanceof MeasureConverterInterface === false) {
                $this->addError($attribute, MeasureHelper::t('Class does not implement `DevGroup\Measure\converters\MeasureConverterInterface` interface'));
            }
        } else {
            $this->addError($attribute, MeasureHelper::t('Class not found'));
        }
    }
696242
public function validateDateEquals($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'date_equals');

        return $this->compareDates($attribute, $value, $parameters, '=');
    }
399737
public function validate($validator)
    {

        // Don't validate empty fields
        if (empty($this->value)) {
            return true;
        }

        if (!Zend_Date::isDate($this->value, $this->getConfig('timeformat'), $this->locale)) {
            $validator->validationError(
                $this->name, _t(
                    'TimeField.VALIDATEFORMAT', "Please enter a valid time format ({format})", array('format' => $this->getConfig('timeformat'))
                ), "validation", false
            );
            return false;
        }
        return true;
    }
438398
public function validateNickname($attribute, $params)
    {
        if (!$this->hasErrors()) {
            if (!$this->_user) {
                $this->addError($attribute, Yii::t('message', 'You enter the user name does not exist oh！'));
            }
        }
    }
641532
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->validateEmpty($object, $attribute);
            return;
        }
        $valid = false;
        if (!is_array($value)) {
            $formats = is_string($this->format) ? [$this->format] : $this->format;
            foreach ($formats as $format) {
                $timestamp = DateTimeParser::parse($value, $format, ['month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0]);
                if (false !== $timestamp) {
                    $valid = true;
                    if (null !== $this->timestampAttribute) {
                        $object->{$this->timestampAttribute} = $timestamp;
                    }
                    break;
                }
            }
        }

        if (!$valid) {
            $this->addError($object, $attribute, $this->message);
        }
    }
335786
public function daysBeforeExpireValidator($attribute)
    {
        if (isset($this->daysBeforeExpire[$this->getZone()])) {
            $minDays = $this->daysBeforeExpire[$this->getZone()];
            $interval = (new DateTime())->diff(new DateTime($this->_model->expires));
            $diff = $interval->format('%a') - $minDays;
            if ($diff > 0) {
                $date = Yii::$app->formatter->asDate((new DateTime())->add(new \DateInterval("P{$diff}D")));
                $this->addError('id', Yii::t('hipanel:domain', 'Domains in zone {zone} could be renewed only in last {min, plural, one{# day} other{# days}} before the expiration date. You are able to renew domain {domain} only after {date} (in {days, plural, one{# day} other{# days}})', ['zone' => (string) $this->getZone(), 'min' => (int) $minDays, 'date' => (string) $date, 'days' => (int) $diff, 'domain' => (string) $this->name]));

                return false;
            }
        }

        return true;
    }
1125180
public function validateUsername( $attribute, $params ) {

		if( !$this->hasErrors() ) {

			if( $this->userService->isExistByUsername( $this->username ) ) {

				$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_USERNAME_EXIST ) );
			}
		}
	}
914680
protected function _formatDate($field, &$attributes)
    {
        if ($this->timestamps && $field) {

            switch ($this->dateFormat) {
                case 'datetime':
                    $dateFormat = date("Y-m-d H:i:s");
                    break;
                
                case 'unixtime':
                default:
                    $dateFormat = time();
                    break;
            }
            
            $attributes[$field] = $dateFormat;
        }

        return $attributes;
    }
373569
public function validateValidatorList($attribute, $value, $parameters)
    {
        $validators = Input::get('validators');
        if (!is_null($validators)) {
            foreach ($validators as $index => $id) {
                if (isset($value[$id]) && $value[$id] == '') {
                    $this->setCustomMessages(["validator_custom[{$id}]" => trans('antares/customfields::validator.create.validators-empty-fields')]);
                    $this->addFailure("validator_custom[{$id}]", "validator_custom[{$id}]", []);
                    break;
                }
            }
        }

        return true;
    }
10001
public function validateDifferent($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'different');

        foreach ($parameters as $parameter) {
            if (! Arr::has($this->data, $parameter)) {
                return false;
            }

            $other = Arr::get($this->data, $parameter);

            if ($value === $other) {
                return false;
            }
        }

        return true;
    }