Convert simplified specification to full form used in validation.

@param array $input specification
@throws LogicException
@return array normalized specification
192555
private function normalizeSpecification(array $input)
    {
        $output = [];
        $mayBeChildless = null;
        
        foreach ($input as $key => $spec) {
            if ($key === 'attributes') {
                if (!is_array($spec)) {
                    throw new LogicException('Value under key '.$key.' have to be an array');
                }
                $output[$key] = [];
                foreach ($spec as $attrName => $attrSpec) {
                    if (is_string($attrName)) {
                        if (!is_array($attrSpec)) {
                            throw new LogicException('Attribute specification have to be an array');
                        }
                        
                        if (!empty($attrSpec['maxLength'])
                            && (!is_int($attrSpec['maxLength']) || $attrSpec['maxLength'] < 1)
                        ) {
                            throw new LogicException('Attribute constraint "maxLength" has to be an integer >= 1');
                        }
                        
                        if (!empty($attrSpec['enum']) && !is_array($attrSpec['enum'])) {
                            throw new LogicException('Attribute constraint "enum" has to be an array');
                        }
    
                        $output[$key][$attrName] = array_merge($this->defaultAttrSpec, $attrSpec);
                    } else {
                        $output[$key][$attrSpec] = $this->defaultAttrSpec;
                    }
                }
                
            } elseif ($key === 'children') {
                $output[$key] = [];
                foreach ($input[$key] as $childKey => $child) {
                    if (is_string($childKey)) {
                        if (!is_array($child)) {
                            throw new LogicException('Invalid child specification for key '.$childKey);
                        }
                        $output[$key][$childKey] = array_merge(
                            $this->defaultChildSpec,
                            $this->normalizeSpecification($child)
                        );
                        if ($mayBeChildless !== false) {
                            $mayBeChildless = $output[$key][$childKey]['mayBeChildless'];
                        }
                    } else {
                        $output[$key][$child] = $this->defaultChildSpec;
                        if ($mayBeChildless !== false) {
                            $mayBeChildless = $output[$key][$child]['mayBeChildless'];
                        }
                    }
                }
    
            } else {
                $output[$key] = $spec;
            }
        }
    
        if (!isset($output['mayBeChildless'])) {
            if ($mayBeChildless !== null) {
                $output['mayBeChildless'] = $mayBeChildless;
            } elseif (isset($this->defaultChildSpec['mayBeChildless'])) {
                $output['mayBeChildless'] = $this->defaultChildSpec['mayBeChildless'];
            }
        }
        
        return $output;
    }
71500
public function save(array $input) : array {
		$input[\Object\Form\Parent2::BUTTON_SUBMIT_SAVE] = true;
		// we must set entry method
		if (isset($this->form->form_object->collection_object->primary_model->column_prefix)) {
			$input[$this->form->form_object->collection_object->primary_model->column_prefix . 'entry_method'] = 'G';
		}
		$this->form->form_object->addInput($input);
		$this->form->form_object->process();
		return $this->form->form_object->apiResult();
	}
1119711
public static function fromArray($input = null)
    {
        //====================================================================//
        // Safety Check
        if (is_null($input) || !self::isValid($input)) {
            return null;
        }
        //====================================================================//
        // return Encoded CheckSum
        return self::getEncoded($input);
    }
405229
protected function validate($input, array &$messages)
    {
        if ($input === '') {
            return;
        }

        $validChars = [];

        foreach ($this->charRanges as $startChar => $endChar) {
            $validChars += array_fill_keys(range($startChar, $endChar), true);
        }

        foreach (str_split($input) as $char) {
            if (!isset($validChars[$char])) {
                $messages[] = new Message(self::MESSAGE, ['valid_chars' => $this->formatCharRanges($this->charRanges)]);
                return;
            }
        }
    }
1246629
public function validate($input)
    {
        $this->errors = [];

        foreach($this->rawRules as $rules){

            list($ruleName, $rule) = $rules;

            // notOf or oneOf
            if ($rule instanceof Validate) {
                $rule->validate($input);
                $this->errors = array_merge($this->errors, $rule->getErrors());
                continue;
            }

            if ($rule instanceof When) {
                $rule->invert = $this->invert;
                $rule->validate($input);
                $this->errors = array_merge($this->errors, $rule->getErrors());
                continue;
            }

            if ($rule instanceof Attributes) {
                $config = [
                    'one' => $this->one,
                    'invert' => $this->invert,
                    'remainder' =>  $this->remainder
                ];
                Instance::configure($rule, $config);
                $rule->validate($input);
                $this->errors = $rule->getErrors();
                break;
            }

            if ($this->skipEmpty && $rule->skipEmpty && $this->isEmpty($input, $rule)) {
                continue;
            }

            if ($rule->validate($input) === !$this->invert) {
                continue;
            }
            $this->errors[$ruleName] = $this->error($ruleName, $rule);
            if ($this->one === true) {
                break;
            }
        }
        return empty($this->errors);
    }
693240
public function validateForm(array $input, $early_exit = false)
    {
        $result = new Result($input);
        foreach ($this->rules as $name => $rules) {
            //skip a value if it is not required...
            if (!isset($this->required[$name])) {
                //and not submitted.
                //here 'submitted' means either not existing or failing submitted()
                if (!isset($input[$name]) || !$this->submitted($input[$name])) {
                    continue;
                }
            }
            $this->doValidation($result, $input, $name, $rules, $early_exit);
        }

        return $result;
    }
1331322
private function validateStoreInputs($inputs)
    {
        $rules = array(
            'selected_products' => 'required_without_all:selected_bundles,pricelist_id',
            'selected_bundles'  => 'required_without_all:selected_products,pricelist_id',
            'pricelist_id'      => 'required_without_all:selected_products,selected_bundles',
            'transaction_id'    => 'required',
            'payment_status'    => 'required',
            'paid'              => 'numeric',
            'email'             => 'required|email'
        );
        
        $messages = [
            'selected_products.required_without_all' =>
                trans('redminportal::messages.order_error_selected_products_required_without_all'),
            'selected_bundles.required_without_all' =>
                trans('redminportal::messages.order_error_selected_bundles_required_without_all'),
            'pricelist_id.required_without_all' =>
                trans('redminportal::messages.order_error_pricelist_id_required_without_all')
        ];

        return Validator::make($inputs, $rules, $messages);
    }
1040556
public function convert( $input ) {

        $result = new SearchResult(
            array(
                'time'       => 0,
                'maxScore'   => 0,
                'totalCount' => $input['SearchCount'],
            )
        );

        $contentService = $this->repository->getContentService();

        foreach ( $input['SearchResult'] as $doc )
        {
            $contentObject = $contentService->loadContent( $doc->ContentObjectID );
            $searchHit = new SearchAndFilterHit(
                array(
                    'score'         => 0,
                    'valueObject'   => $contentObject,
                    'objectStates'  => $this->loadContentObjectStates( $contentObject->contentInfo )
                )
            );
            $result->searchHits[] = $searchHit;
        }
        return $result;
    }
315527
public function normalize($input)
    {
        foreach ($this->normalizers as $normalizer) {
            if ($normalizer->accept($input)) {
                $input = $normalizer->normalize($input);
            }
        }

        return $input;
    }
707241
protected function convertToValidCharacters(string $input): string
    {
        $converted = preg_replace(
            '/[\\p{C}\\p{Z}\\p{M}]+/u',
            '',
            \Normalizer::normalize(str_replace('～', '〜', $input), \Normalizer::FORM_KC)
        );
        if ($this->isRegExp($converted)) {
            $converted = trim($converted, '/');
        }
        return $converted;
    }
638536
public function verifyWithExtra($inputs)
    {
        $result = $this->restCall('PaymentVerificationWithExtra.json', $inputs);

        if ($result['Status'] == 100) {
            return [
                'Status'      => 'success',
                'RefID'       => $result['RefID'],
                'ExtraDetail' => $result['ExtraDetail'],
            ];
        } elseif ($result['Status'] == 101) {
            return [
                'Status'      => 'verified_before',
                'RefID'       => $result['RefID'],
                'ExtraDetail' => $result['ExtraDetail'],
            ];
        } else {
            return [
                'Status'    => 'error',
                'error'     => !empty($result['Status']) ? $result['Status'] : null,
                'errorInfo' => !empty($result['errors']) ? $result['errors'] : null,
            ];
        }
    }
1126986
public function validate($input): bool
    {
        return $this->less($this->minValue, $input)
            && $this->less($input, $this->maxValue);
    }
900825
protected function parseType(array $input)
    {
        /** @var string $type */
        /** @var string[] $types */
        extract($input);
        switch ($type) {
            case 'array':
                if (!is_array($this->{$key}))
                    return false;
                break;
            case 'int':
            case 'integer':
                if (!is_int($this->{$key}))
                    return false;
                break;
            case 'or':
                $valid = false;
                foreach ($types as $_type) {
                    if (gettype($this->{$key}) == $_type) {
                        $valid = true;
                        break;
                    }
                }
                if (!$valid) return false;
                break;
            default:
                //throw new Exception('Incorrect rule');
                return null;
        }
        return true;
    }
204062
public function convert($input)
    {
        if (is_string($input) === false) {
            throw new \InvalidArgumentException('Expected a string value at Parsedown converter.');
        }

        $converter = new \ParsedownExtra();

        return $converter->text($input);
    }
199796
private static function isValid($input)
    {
        if (!is_array($input)) {
            return false;
        }
        foreach ($input as $value) {
            if (!is_scalar($value)) {
                return false;
            }
        }

        return true;
    }
227498
public function create(array $input, array $rules): Validator
	{
		$validator = new Validator($input, $rules, $this->i18n, $this->container);

		foreach($this->rules as $rule => $ruleClass)
		{
			$validator->extend($rule, $ruleClass);
		}

		return $validator;
	}
179293
public function check(array $input)
    {
        $result = $this->spec->check($input);

        return new SpecResult(
            $result->getMissing(),
            Arr::walkCopy(
                $result->getFailed(),
                function ($key, $value, &$array, $path) {
                    $array[$key] = Std::coalesce(
                        Std::firstBias(
                            Arr::dotGet(
                                $this->messages,
                                Std::nonempty($path, $key)
                            ) !== null,
                            [Arr::dotGet(
                                $this->messages,
                                Std::nonempty($path, $key)
                            )],
                            null
                        ),
                        Std::firstBias(
                            $value instanceof AbstractConstraint,
                            function () use ($value) {
                                return $value->getDescription();
                            },
                            null
                        ),
                        Std::firstBias(
                            is_array($value),
                            function () use ($value) {
                                return array_map(
                                    function (AbstractConstraint $item) {
                                        return $item->getDescription();
                                    },
                                    $value
                                );
                            },
                            $value
                        )
                    );
                },
                true,
                '',
                false
            ),
            $result->getStatus()
        );
    }