Normalizes the attribute specifications.
@throws InvalidConfigException
354091
protected function normalizeAttributes()
    {
        if ($this->attributes === null) {
            if ($this->model instanceof Model) {
                $this->attributes = $this->model->attributes();
            } elseif (is_object($this->model)) {
                $this->attributes = $this->model instanceof Arrayable ? $this->model->toArray() : array_keys(get_object_vars($this->model));
            } elseif (is_array($this->model)) {
                $this->attributes = array_keys($this->model);
            } else {
                throw new InvalidConfigException('The "model" property must be either an array or an object.');
            }
            sort($this->attributes);
        }

        foreach ($this->attributes as $i => $attribute) {
            if (is_string($attribute)) {
                if (!preg_match('/^([\w\.]+)(:(\w*))?(:(.*))?$/', $attribute, $matches)) {
                    throw new InvalidConfigException('The attribute must be specified in the format of "attribute", "attribute:format" or "attribute:format:label"');
                }
                $attribute = [
                    'attribute' => $matches[1],
                    'format' => isset($matches[3]) ? $matches[3] : 'text',
                    'label' => isset($matches[5]) ? $matches[5] : null,
                ];
            }

            if (!is_array($attribute)) {
                throw new InvalidConfigException('The attribute configuration must be an array.');
            }

            if (isset($attribute['visible']) && !$attribute['visible']) {
                unset($this->attributes[$i]);
                continue;
            }

            if (!isset($attribute['format'])) {
                $attribute['format'] = 'text';
            }
            if (isset($attribute['attribute'])) {
                $attributeName = $attribute['attribute'];
                if (!isset($attribute['label'])) {
                    $attribute['label'] = $this->model instanceof Model ? $this->model->getAttributeLabel($attributeName) : Inflector::camel2words($attributeName, true);
                }
                if (!array_key_exists('value', $attribute)) {
                    $attribute['value'] = ArrayHelper::getValue($this->model, $attributeName);
                }
            } elseif (!isset($attribute['label']) || !array_key_exists('value', $attribute)) {
                throw new InvalidConfigException('The attribute configuration requires the "attribute" element to determine the value and display label.');
            }

            $this->attributes[$i] = $attribute;
        }
    }
784198
public static void validate(String styleAttribute) throws InvalidInputException {
    try {
      final Map<String, String> styleMap = Splitter.on(";").omitEmptyStrings().withKeyValueSeparator(":").split(styleAttribute);
      final HashSet<String> inputStyleProperties = new HashSet<>(styleMap.keySet());
      inputStyleProperties.removeAll(ALLOWED_PROPERTIES);
      if (!inputStyleProperties.isEmpty()) {
        throw new InvalidInputException("Invalid property(s): [" + Joiner.on(",").join(inputStyleProperties) + "] in the \"style\" attribute");
      }
    } catch (IllegalArgumentException ex) {
      throw new InvalidInputException("Unparseable \"style\" attribute: " + styleAttribute, ex);
    }
  }
288202
protected function normalize_mapping() {
		$mapping = [];

		foreach ( $this->maps as $attribute => $metadata ) {
			// Allowed using same name of attribute and metadata.
			// Eg: [gallery] same as [gallery => gallery].
			$attribute = is_int( $attribute ) ? $metadata : $attribute;

			if ( array_key_exists( $attribute, $this->attributes ) ) {
				$mapping[ $attribute ] = $metadata;
			}
		}

		return $mapping;
	}
356912
public function init()
    {
        if ($this->dataProvider === null) {
            throw new InvalidConfigException('The "dataProvider" property must be set');
        }
        $this->channelAttributes = $this->getAttributes($this->channel);
        foreach ($this->requiredChannelElements as $channelElement) {
            if (!in_array($channelElement, $this->channelAttributes)) {
                throw new InvalidConfigException('Required channel attribute "' . $channelElement . '" must be set');
            }
        }
        $this->itemAttributes = $this->getAttributes($this->items);
        foreach ($this->requiredItemElements as $itemElement) {
            if (!in_array($itemElement, $this->itemAttributes)) {
                throw new InvalidConfigException('Required item attribute "' . $itemElement . '" must be set');
            }
        }
        $this->feed = new Feed;
    }
442638
public function init()
	{
		parent::init();

		if (empty($this->statusAttribute)) {
			throw new InvalidConfigException('The "statusAttribute" configuration for the Behavior is required.');
		}

		// init source
		
		if (empty($this->source)) {
			throw new InvalidConfigException('The "source" configuration for the Behavior can\'t be empty.');
		} elseif (  ! Yii::$app->has($this->source)) {
			Yii::$app->set($this->source, ['class'=> self::DEFAULT_SOURCE_CLASS]);
		}
		$this->_wfSource = Yii::$app->get($this->source);

		// init Event Sequence
		
		if ( $this->eventSequence == null) {
			$this->_eventSequence = null;
		} elseif ( is_string($this->eventSequence)) {
			if (  ! Yii::$app->has($this->eventSequence)) {
				Yii::$app->set($this->eventSequence, ['class'=> self::DEFAULT_EVENT_SEQUENCE_CLASS]);
			}
			$this->_eventSequence = Yii::$app->get($this->eventSequence);
		} else {
			throw new InvalidConfigException('Invalid "eventSequence" value.');
		}
	}
915141
public function init()
    {
        NestableAsset::register($this->getView());
        if ($this->dataProvider !== null) {
            $this->prepareItems();
        }
        if ($this->items === null) {
            throw new InvalidConfigException('The "dataProvider" property or "items" property must be set at least one.');
        }
        Html::addCssClass($this->options, $this->rootClass);

        if (!ArrayHelper::keyExists('id', $this->options)) {
            $this->options['id'] = uniqid('w_');
        }

    }
421406
public function init ()
		{
			if (!in_array($this->layout, [ 'default', 'horizontal', 'inline' ]))
				throw new InvalidConfigException('Invalid layout type: ' . $this->layout);

			if ($this->layout !== 'default')
				Html::addCssClass($this->options, 'form-' . $this->layout);

			if ($this->name)
				$this->options[ 'name' ] = $this->name;

			parent::init();
		}
482532
public function normalize() {
        $len =  $this->length();

        if ($len === 0.0) {
            return;
        }
        $count = count($this->elements);
        for ($i=0;$i<$count;$i++) {
            $this[$i] /= $len;
        }
    }
109432
def normal_attributes
        normalized = {}
        attributes.each_pair do |attr, value|
          property = active_fedora_class.properties[attr.to_s]
          # This handles some cases where the attributes do not directly map to an
          #   RDF property value
          normalized[attr] = value
          next if property.nil?
          normalized[attr] = Array.wrap(value) if property.multiple?
        end
        normalized
      end
1138386
public function init()
    {
        parent::init();

        if (empty($this->model)) {
            throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "model" property must be set.'));
        }

        if (empty($this->pjaxContainerId)) {
            $this->pjaxContainerId = 'comment-pjax-container-' . $this->getId();
        }

        if (empty($this->model->{$this->entityIdAttribute})) {
            throw new InvalidConfigException(Yii::t('yii2mod.comments', 'The "entityIdAttribute" value for widget model cannot be empty.'));
        }

        $this->entity = hash('crc32', get_class($this->model));
        $this->entityId = $this->model->{$this->entityIdAttribute};

        if (empty($this->relatedTo)) {
            $this->relatedTo = get_class($this->model) . ':' . $this->entityId;
        }

        $this->encryptedEntity = $this->getEncryptedEntity();
        $this->commentWrapperId = $this->entity . $this->entityId;

        $this->registerAssets();
    }
815712
public function init()
    {
        if (empty($this->options['shortname'])) {
            throw new InvalidConfigException('Property "shortname" must be set in settings.');
        }
        if ($this->credits === null) {
            $this->credits = Html::a('Comments powered by Disqus', 'http://disqus.com/?ref_noscript');
        }
        $this->noScript = "Please enable JavaScript to view the {$this->credits}.";
    }
263776
protected function normalizeOptions()
    {
        // not allowed empty container
        !$this->containerTag && $this->containerTag = 'div';

        if(!isset($this->containerOptions['id']) || empty($this->containerOptions['id'])) {
            $this->containerOptions['id'] = $this->getId();
        }
    }
332329
function normalizeComponentAttributes(component, isAngleBracket, attrs) {
    var normalized = {};
    var attributeBindings = component.attributeBindings;
    var streamBasePath = component.isComponent ? '' : 'view.';
    var i, l;

    if (attrs.id && _emberHtmlbarsHooksGetValue.default(attrs.id)) {
      // Do not allow binding to the `id`
      normalized.id = _emberHtmlbarsHooksGetValue.default(attrs.id);
      component.elementId = normalized.id;
    } else {
      normalized.id = component.elementId;
    }

    if (attributeBindings) {
      for (i = 0, l = attributeBindings.length; i < l; i++) {
        var attr = attributeBindings[i];
        var colonIndex = attr.indexOf(':');

        var attrName, expression;
        if (colonIndex !== -1) {
          var attrProperty = attr.substring(0, colonIndex);
          attrName = attr.substring(colonIndex + 1);
          expression = ['get', '' + streamBasePath + attrProperty];
        } else if (attrs[attr]) {
          // TODO: For compatibility with 1.x, we probably need to `set`
          // the component's attribute here if it is a CP, but we also
          // probably want to suspend observers and allow the
          // willUpdateAttrs logic to trigger observers at the correct time.
          attrName = attr;
          expression = ['value', attrs[attr]];
        } else {
          attrName = attr;
          expression = ['get', '' + streamBasePath + attr];
        }

        _emberMetalDebug.assert('You cannot use class as an attributeBinding, use classNameBindings instead.', attrName !== 'class');

        normalized[attrName] = expression;
      }
    }

    if (isAngleBracket) {
      for (var prop in attrs) {
        var val = attrs[prop];
        if (!val) {
          continue;
        }

        if (typeof val === 'string' || val.isConcat) {
          normalized[prop] = ['value', val];
        }
      }
    }

    if (attrs.tagName) {
      component.tagName = attrs.tagName;
    }

    var normalizedClass = normalizeClass(component, attrs, streamBasePath);

    if (normalizedClass) {
      normalized.class = normalizedClass;
    }

    if (_emberMetalProperty_get.get(component, 'isVisible') === false) {
      var hiddenStyle = ['subexpr', '-html-safe', ['display: none;'], []];
      var existingStyle = normalized.style;

      if (existingStyle) {
        normalized.style = ['subexpr', 'concat', [existingStyle, ' ', hiddenStyle], []];
      } else {
        normalized.style = hiddenStyle;
      }
    }

    return normalized;
  }
1098990
private function checkAttrExists($attribute)
    {
        foreach ($this->attributes as $attr => $options) {
            $this->ensureAttributes($attr, $options);
            if ($attr == $attribute) {
                return;
            }
        }
        throw new InvalidParamException();
    }
1270884
protected function validateFromAttributes()
    {
        $value = $this->attribs['value'];
        if (\strlen($value) == 0) {
            $this->debug->log('empty value');
            if ($this->isRequired()) {
                $this->flag();
            }
        } elseif (isset($this->attribs['pattern']) && !\preg_match('/^'.\str_replace('/', '\/', $this->attribs['pattern']).'$/', $value)) {
            $this->debug->log('pattern mismatch');
            $this->flag('invalid format');
        } elseif (isset($this->attribs['max']) && \preg_replace('/[^-\d\.]/', '', $value) > $this->attribs['max']) {
            $this->debug->log('too big');
            $this->flag('value is too large');
        } elseif (isset($this->attribs['min']) && \preg_replace('/[^-\d\.]/', '', $value) < $this->attribs['min']) {
            $this->debug->log('too small');
            $this->flag('value is too small');
        } elseif (isset($this->attribs['maxlength']) && \mb_strlen($value) > $this->attribs['maxlength']) {
            $this->debug->log('too long');
            if (empty($this->props['invalidReason'])) {
                $this->props['invalidReason'] = 'Value is too long';
            }
            $this->flag($this->props['invalidReason']);
        }
    }
304354
protected function normalizeCrs()
    {
        $type = $this->props['attribs']['type'];
        if (empty($this->props['options'])) {
            $this->props['options'] = array();
            if ($type == 'checkbox') {
                $this->props['options'][] = array(
                    'value' => 'on',
                    'label' => $this->props['label'],
                    'attribs' => $this->props['attribs'],
                );
                $this->props['label'] = null;
                unset($this->props['attribs']['value']);
            }
        }
        if ($type == 'checkbox' && $this->props['checkboxGroup'] === 'auto') {
            $this->props['checkboxGroup'] = \count($this->props['options']) > 1;
        }
        foreach ($this->props['options'] as $key => $option) {
            if (!\is_array($option)) {
                $this->props['options'][$key] = array(
                    'label' => $option,
                    'attribs' => array(
                        'value' => \is_string($key)
                            ? $key
                            : $option,
                    ),
                );
            } else {
                $option = $this->moveShortcuts($option);
                if (!isset($option['label']) && isset($option['attribs']['value'])) {
                    $option['label'] = $option['attribs']['value'];
                }
                $this->props['options'][$key] = $option;
            }
        }
        if (\in_array($type, array('checkbox','select')) && !isset($this->props['values'])) {
            /*
                values may be passed as an alternate way of specifying which values are checked/selected
                single checkbox:
                    passing 'value' is considered the option (not user supplied value) unless options array is non-empty
            */
            $this->props['values'] = isset($this->attribs['value'])
                ? (array) $this->attribs['value']
                : array();
            unset($this->attribs['value']);
        }
    }
929088
def _normalize_default_setter(self, mapping, schema, field):
        
        if 'default_setter' in schema[field]:
            setter = schema[field]['default_setter']
            if isinstance(setter, _str_type):
                setter = self.__get_rule_handler('normalize_default_setter',
                                                 setter)
            mapping[field] = setter(mapping)