Normalise the options for selector.

@param array $options The form options
@param array $value   The options of form type

@return array The normalized options for selector
973048
protected function normalizeOptions(array $options, array $value)
    {
        return $options['select2']['enabled']
            ? array_merge($value, [
                'error_bubbling' => false,
                'multiple' => false,
                'select2' => array_merge($options['select2'], [
                    'tags' => $options['allow_add'],
                ]),
            ])
            : $value;
    }
1175335
public static function string(&$value, $options = ['length'=>null, 'regex'=>null, 'default'=>null])
    {
        $value = htmlspecialchars(trim($value));
        self::processString($value, $options);
        return $value;
    }
163758
public function fromString($value, $type, array $options)
    {
        return $this->convert($value, $type, $options, $this->getFromStringCallbacks());
    }
376219
public function validate($value, $options)
	{
		$this->value = $value;
		$this->options = $options;
		$this->errors = [];

		return $this->checkIt();
	}
678479
public function filter($value, $options = [])
    {
        if ($this->getPattern() == null) {
            $ex = new \Exception(get_class($this) . ' does not have a valid MatchPattern set.');
            throw $ex;
        }

        return preg_replace($this->getPattern(), $this->getReplacement(), $value);
    }
286704
public static function selectOption($option, $value)
    {
        $attributes = [''];

        $attributes[] = "value=\"{$option['value']}\"";

        if (
            (is_array($value) && in_array($option['value'], $value))
            || ($option['value'] == $value)
        ) {
            $attributes[] = 'selected="selected"';
        }

        $attributes = implode(' ', $attributes);
        return "<option {$attributes}>{$option['label']}</option>";
    }
107795
protected function _normalizeArray($value)
    {
        if ($value instanceof stdClass) {
            $value = (array) $value;
        }

        if (is_array($value)) {
            return $value;
        }

        if (!($value instanceof Traversable)) {
            throw $this->_createInvalidArgumentException($this->__('Not an iterable'), null, null, $value);
        }

        $value = iterator_to_array($value, true);

        return $value;
    }
769914
public function isValid($value = null, array $options = []): bool
    {
        if (\count($options) > 0) {
            $this->setOptions($options);
        }
        $this->setValue($value);
        $this->errors = [];

        switch ($this->options['type']) {
            case 'equals':
                $isValid = $this->validateEquals();
                break;
            case 'lower-than':
                $isValid = $this->validateLowerThan();
                break;
            case 'greater-than':
                $isValid = $this->validateGreaterThan();
                break;
            default:
                $isValid = $this->validateEquals();
                break;
        }

        return $isValid;
    }
882440
public function transform($value, array $options = [])
    {
        if (null === $value) {
            return null;
        }
        if (!$value instanceof ResourceInterface) {
            throw new \UnexpectedValueException('Expecting a ResourceInterface as input');
        }
        $resolver = new OptionsResolver();
        $this->configureOptions($resolver);
        $options = $resolver->resolve($options);

        return $this->findAsset($value, $options);
    }
112489
public static function submit($value, array $options = [])
    {
        self::exclure($options, ['type', 'value']);

        return self::input('submit', 'null', $value, $options);
    }
103635
public static function enum($value, $options){

		$value = static::_nullValue($value);

		if(!in_array($value, $options)){

			return null;
		}

		return $value;
	}
1094510
protected function normalizeSizeOption(array &$options)
    {
        if (isset($options['size'])) {
            $size = explode('x', $options['size']);
            if (
                isset($size[0]) &&
                isset($size[1]) 
            ) {
                list($options['cols'], $options['rows']) = $size;
            }
            unset($options['size']);
        }
    }
608874
protected function normalizeValue($value)
    {
        if (is_array($value)) {
            $value = $this->normalizeArray($value);
        } elseif (is_bool($value)) {
            $value = $this->normalizeBoolean($value);
        } elseif (is_null($value)) {
            $value = 'null';
        } elseif (is_string($value) && $this->checkFlag(self::STRING_MODE_QUOTE)) {
            $value = sprintf('"%s"', $value);
        }

        return $value;
    }
395079
protected static function processString(&$value, $options)
    {
        $value = str_replace(chr(0), '', $value);
        if (isset($options['length']) && $options['length']) {
            $value = substr($value, 0, $options['length']);
        }

        if (isset($options['regex']) && $options['regex']) {
            if (!preg_match($options['regex'], $value)) {
                $value = null;
            }
        }
    }
390730
public function filter($value, array $options = [])
    {
        if ( ! is_string($value)) return $value;

        $value = trim($value);

        if ( ! Str::startsWith($value, ['http://', 'https://'])) {
            $value = "http://$value";
        }

        return filter_var($value, FILTER_SANITIZE_URL);
    }
584282
public function submit($value = null, $options = [])
    {
        $options['type'] = 'submit';
        $options = $this->appendClassToOptions(Config::get('form-builder.submit-class'), $options);

        return $this->button($value, $options);
    }
345275
public function filter($value, array $options = [])
    {
        if ( ! is_string($value) || empty(trim($value)))
            return $value;

        $this->checkOptions($options);

        list($currentFormat, $targetFormat) = array_map('trim', $options);

        return DateTime::createFromFormat($currentFormat, $value)->format($targetFormat);
    }