Validates a field widget type
@return boolean|null
198588
protected function validateWidgetField()
    {
        $field = 'widget';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Widget');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        $types = $this->field->getWidgetTypes();

        if (empty($types[$value])) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }
640768
public function getFieldValue() {

		switch( $this->type ) {

			case self::TYPE_TEXT:
			case self::TYPE_TEXTAREA:
			case self::TYPE_RADIO:
			case self::TYPE_RADIO_GROUP:
			case self::TYPE_SELECT:
			case self::TYPE_RATING:
			case self::TYPE_ICON:
			case self::TYPE_CHECKBOX_GROUP: {

				return $this->value;
			}
			case self::TYPE_PASSWORD: {

				return null;
			}
			case self::TYPE_CHECKBOX:
			case self::TYPE_TOGGLE: {

				return Yii::$app->formatter->asBoolean( $this->value );
			}
		}
	}
855141
private function validate() {
        $filterer = new Filterer();
        $valid = true;
        foreach ($this->elements as $element) {
            if (!$element->validate($filterer, $this->data))
                $valid = false;
            $this->data[$element->name] = ($element->type === 'fieldset') ?
                    $element->options->value->getData(true) : $element->data;
        }
        $this->valid = $valid;
        return $valid;
    }
379483
protected function validateClassProduct()
    {
        $field = 'product_class_id';
        $value = $this->getSubmitted($field);

        if (empty($value)) {
            return null;
        }

        $label = $this->translation->text('Product class');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $product_class = $this->product_class->get($value);

        if (empty($product_class)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        $fields = $this->product_class->getFields($value);
        $this->setSubmitted('product_fields', $fields);
        return true;
    }
1202305
public function isValid ()
    {
        return !$this->isEmpty() && !Helper::some($this->getFields(), function (Field $field) { return $field->isEmpty(); });
    }
26323
protected function validateItemsProductBundle()
    {
        $field = 'bundle';
        $value = $this->getSubmitted($field);

        if (empty($value)) {
            return null;
        }

        if (!is_array($value)) {
            $this->setErrorInvalid($field, $this->translation->text('Product bundle'));
            return false;
        }

        $main_product = $this->getSubmitted('product');

        $loaded = array();

        foreach ($value as $product_id) {

            if (isset($loaded[$product_id])) {
                $this->setError($field, $this->translation->text('All bundled products must be unique'));
                return false;
            }

            $product = $this->product->get($product_id);

            $loaded[$product_id] = $product;

            if (empty($product['status'])) {
                $this->setError($field, $this->translation->text('Some of bundled products are unavailable'));
                return false;
            }

            if ($main_product['product_id'] == $product['product_id']) {
                $this->setError($field, $this->translation->text('Bundled products cannot be the same as the main product'));
                return false;
            }

            if ($main_product['store_id'] != $product['store_id']) {
                $this->setError($field, $this->translation->text('All bundled products must belong to the same store'));
                return false;
            }
        }

        $this->setSubmitted('products', $loaded);
        return true;
    }
259141
public function validate()
    {
        $this->debug->groupCollapsed(__METHOD__, $this->attribs['name']);
        $this->props['isValid'] = true;
        $this->classRemove($this->props['attribsContainer'], 'has-error');
        $attribs = $this->attribs;
        if (\in_array($attribs['type'], array('checkbox','radio','select'))) {  // these types use the 'options' array
            $this->validateCrs();
        } elseif (\in_array($attribs['type'], array('submit','reset','image'))) {
            $this->debug->log('not checking');
        } elseif (!empty($this->props['newPage'])) {
            $this->debug->log('not checking newPage');
        } elseif (\in_array($attribs['type'], array('file'))) {
            $this->debug->log($attribs['name'].' is a file type');
            if ($this->isRequired() && empty($attribs['disabled']) && empty($attribs['value'])) {
                $this->flag();
            }
        } elseif ($this->isRequired() || $this->props['flagNonReqInvalid']) {
            if (!empty($attribs['placeholder']) && $attribs['value'] === $attribs['placeholder']) {
                $this->debug->log('value == placeholder');
                $attribs['value'] = null;
            }
            $this->validateFromAttributes();
        }
        if ($this->props['isValid']) {
            $isValid = $this->doValidate();
            // validate callback may call flag() directly
            if ($this->props['isValid'] && !$isValid) {
                $this->flag();
            }
        }
        $this->debug->groupEnd();
        return $this->props['isValid'];
    }
1197601
protected function validateUser()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->user->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('User'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
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');
    }
1096069
protected function validateColorFieldValue()
    {
        $field = 'color';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (!isset($value) || $value === '') {
            return null;
        }

        if (preg_match('/#([a-fA-F0-9]{3}){1,2}\b/', $value) !== 1) {
            $this->setErrorInvalid($field, $this->translation->text('Color'));
            return false;
        }

        // HTML5 color field cannot have empty value
        // Default value is #000000
        // Assuming black is empty
        if ($value === '#000000') {
            $this->setSubmitted($field, '');
        }

        return true;
    }
1130616
protected function validateZoneCountryState()
    {
        $field = 'zone_id';
        $value = $this->getSubmitted($field);

        if (empty($value)) {
            return null;
        }

        $label = $this->translation->text('Zone');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $zone = $this->zone->get($value);

        if (empty($zone)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }
1266455
private function isValidWidgetFile($widgetType)
    {
        //====================================================================//
        // Verify Local Path Exist
        if (false == $this->isValidLocalPath()) {
            return false;
        }
        //====================================================================//
        // Verify Object File Exist
        $filename = Splash::getLocalPath().'/Widgets/'.$widgetType.'.php';
        if (false == file_exists($filename)) {
            $msg = 'Local Widget File Not Found.</br>';
            $msg .= 'Current Filename : '.$filename.'';

            return Splash::log()->err($msg);
        }

        return true;
    }
1130812
protected function validateEmail()
    {
        $field = 'email';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('E-mail');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        return true;
    }
1246312
protected function validate()
    {
        foreach ($this->_requiredAttr as $attr) {
            if (is_array($attr)) {
                $valid = false;
                foreach ($attr as $sub) {
                    if (!is_null($this->$sub)) {
                        $valid = true;
                        break;
                    }
                }
                if (!$valid) {
                    return false;
                }
            } elseif (is_null($this->$attr)) {
                return false;
            }
        }
        return true;
    }
569831
protected function validateNull($value, ValidationField $field) {
        if ($value === null) {
            return null;
        }
        $field->addError('type', ['messageCode' => 'The value should be null.', 'type' => 'null']);
        return Invalid::value();
    }
527138
public function validated($field = null, $default = false)
	{
		if ($field === null)
		{
			return $this->validated;
		}

		return array_key_exists($field, $this->validated) ? $this->validated[$field] : $default;
	}
285758
public function getFormWidget($field)
    {
        if (isset($this->formWidgets[$field])) {
            return $this->formWidgets[$field];
        }

        return null;
    }