Validate the IodefElement's attributes and value.
@return boolval
493546
protected function validate()
    {
        // If attributes are set, validate them.
        if (!empty($this->attributes)) {
            // It's possible that there are no rules for the attributes available.
            // If so, skip attribute validation.
            if (sizeof($this->getAttributeRules()) > 0) {
                $validate_attributes = new Validator($this->attributes);
                $validate_attributes->rules($this->getAttributeRules());

                // Validation failed to succeeed, show errors
                if (!$validate_attributes->validate()) {
                    echo 'Some attributes failed to pass the validator:';
                    foreach ($validate_attributes->errors() as $failed_attr) {
                        echo ' '. $failed_attr[0];
                    }
                    return false;
                }
            }
        }

        // If a value is set, validate it.
        if (array_key_exists('value', $this)) {
            // It's possible that there is no value rule set.
            // If so, skip value validation.
            if (sizeof($this->getValueRule()) > 0) {
                $validate_value = new Validator(['value' => $this->value]);
                $validate_value->rules($this->getValueRule());

                // Validation failed to succeeed, show errors
                if (!$validate_value->validate()) {
                    echo "The 'value' failed to pass the validator:";
                    foreach ($validate_value->errors() as $message) {
                        if (is_array($message)) {
                            $message = implode(',', $message);
                        }
                        echo ' '. strtolower($message);
                    }
                    return false;
                }
            }
        }

        return true;
    }
676047
public function validate()
	{
		// Process each element.
		$instance_taxonomy = $this->getInstanceTaxonomy();
		$types = $instance_taxonomy->context->types;
		// Create a collection of prefixes from this document and the backing schema(s)
		// BMS 2018-08-22 Added the array_filter() call so that taxonomies without a prefix do not cause a log notice
		// $prefixes = array_flip( array_map( function( $taxonomy ) { return $taxonomy->getPrefix(); }, $instance_taxonomy->getImportedSchemas() ) );
		$prefixes = array_flip( array_filter( array_map( function( $taxonomy ) { return $taxonomy->getPrefix(); }, $instance_taxonomy->getImportedSchemas() ) ) );

		$prefixes = $this->instance_namespaces + $prefixes + array( STANDARD_PREFIX_XBRLI => XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLI ] );

		if ( is_null( $types ) )
		{
			throw new \ErrorException( 'Unable to validate the instance because there are no types' );
		}

		// Begin by checking the element in the xbrli namespace are valid
		$xml = $this->getInstanceXml();

		if ( strcasecmp( $xml->getName(), STANDARD_PREFIX_XBRL ) !== 0 )
		{
			$this->log()->instance_validation( "4.1", "The instance document root element is not 'xbrl'.", array() );
			return false;
		}

		$rootElement = $types->getElement( STANDARD_PREFIX_XBRL, STANDARD_PREFIX_XBRLI );

		// The requirements for the <xbrl> root node are described in the schema type.  In summary:
		// 1) There *must* be a schemaref element and it *must* precede all other nodes
		// 2) There *may* be linkrbaseRef, roleRef, an arcroleRefs (in this order)
		// 3) There will be zero or more elements belonging to xbrli:item, xbrli:tuple, xbrli:context, xbrli:unit or link:footnoteLink substitution groups

		// The root element *must* have a schemaRef element and at least one each of a fact, unit and context

		if ( ! count( $this->instance_xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->schemaRef ) )
		{
			$this->log()->instance_validation( "4.2", "There must be at least one schemaRef element in the instance document", array() );
		}
		else
		{
			// The schemaRef MUST have an 'href' attribute and 'type' attribute
			foreach ( $this->instance_xml->children( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_LINK ] )->schemaRef as $schemaRefKey => $schemaRef )
			{
				$attributes = $schemaRef->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XLINK ] );

				if ( ! property_exists( $attributes, 'type' ) )
				{
					$this->log()->instance_validation( "4.2.1", "There must be a type attribute on the schemaRef element ", array() );
				}
				else if ( (string) $attributes->type != 'simple' )
				{
					$this->log()->instance_validation( "4.2.1", "The value of the type attribute on the schemaRef element must be 'simple'", array() );
				}

				if ( ! property_exists( $attributes, 'href' ) )
				{
					$this->log()->instance_validation( "4.2.2", "There must be an href attribute on the schemaRef element ", array() );
				}
			}
		}

		$numericTypes = false;
		foreach ( $this->getElements()->getItemTypes() as $key => $typeName )
		{
			// Look up the type in the types list to see if it is numeric
			$qName = qname( $typeName, $prefixes );
			if ( $types->isNumeric( $qName ) )
			{
				$numericTypes = true;
				break;
			}
		}

		if ( count( $this->elements ) > 0 && ( ! count( $this->contexts ) ) )
		{
			$this->log()->instance_validation( "4.6.1", "If there are facts defined there must also be at least one context defined", array() );
		}

		if ( $numericTypes && ! count( $this->units ) )
		{
			$this->log()->instance_validation( "4.6.2", "If there are numeric facts defined (pure, shares, monetary items, etc.) there must also be at least one unit defined", array() );
		}

		// Next check that the contexts are valid
		$contexts = $this->getContexts();

		// if is instant make sure the date exists and is valid
		// if is start/end make sure both dates exist, are valid and the end > start
		// check segment or scenario
		//   check the children do not use namespaceUri http://xbrl.org/2006/xbrldi
		//   check the children are themselves not concepts

		foreach ( $this->contexts as $id => $context )
		{
			/* ---------------------------------------------------------
			 * Validate the ID
			 * ---------------------------------------------------------
			 */
			if ( empty( $id ) ) // Should never happen here because these should be filtered when the context is read
			{
				$this->log()->instance_validation( "4.7.1", "All contexts must have a valid id", array() );
			}

			/* ---------------------------------------------------------
			 * Validate the period
			 * ---------------------------------------------------------
			 */
			$period = $context['period'];

			if ( ! isset( $period['startDate'] ) )
			{
				$this->log()->instance_validation( "4.7.2", "A start date must be defined", array( 'context' => $id ) );
			}

			if ( ! isset( $period['startDate'] ) )
			{
				$this->log()->instance_validation( "4.7.2", "An end date must be defined", array( 'context' => $id ) );
			}

			if ( ! isset( $period['startDate'] ) || ! isset( $period['startDate'] ) ) continue;

			// Check the start dates and the end dates are valid
			$validDate = function( $date )
			{
				// Could be 'forever'
				if ( $date == 'forever' ) return true;

				// Next try using a full ISO8601 formatted date
				$result = DateTime::createFromFormat( DATE_ATOM, $date );
				if ( $result ) return true;

				// Next try using an ISO8601 formatted date but without the time zone
				$result = DateTime::createFromFormat( "Y-m-d\TH:i:s", $date );
				if ( $result ) return true;

				// Now try just the date
				$result = DateTime::createFromFormat( "Y-m-d", $date );
				if ( $result ) return true;

				return false;
			};

			if ( ! $validDate( $period['startDate'] ) )
			{
				$this->log()->instance_validation( "4.7.2", "The start date must be a valid ISO 8601 date",
					array(
						'context' => $id,
						'date' => "{$period['startDate']}",
					)
				);
			}

			if ( ! $validDate( $period['endDate'] ) )
			{
				$this->log()->instance_validation( "4.7.2", "The end date must be a valid ISO 8601 date",
					array(
						'context' => $id,
						'date' => "{$period['endDate']}",
					)
				);
			}

			if ( $period['type'] == 'instant' )
			{
				// Both the dates must be the same
				if ( $period['startDate'] != $period['endDate'] )
				{
					$this->log()->instance_validation( "4.7.2", "In an 'instant' context the start date and end dates must be the same",
						array(
							'context' => $id,
							'startdate' => "{$period['startDate']}",
							'enddate' => "{$period['endDate']}",
						)
					);
				}
			}
			else if ( $period['type'] == 'forever' )
			{
				// Both the dates must be the same
				if ( $period['startDate'] != $period['endDate'] )
				{
					$this->log()->instance_validation( "4.7.2", "In an 'forever' context the start date and end dates must be the same",
						array(
							'context' => $id,
							'startdate' => "{$period['startDate']}",
							'enddate' => "{$period['endDate']}",
						)
					);
				}
			}
			else
			{
				// For duration context the end date must be greater than the start date
				$startDate = $period['startDate'];
				if ( ! strpos( $startDate, 'T' ) ) $startDate .= "T00:00:00Z";

				$endDate = $period['endDate'];
				if ( ! strpos( $endDate, 'T' ) ) $endDate .= "T23:59:59Z";

				$diff = DateTime::createFromFormat( DATE_ATOM, $endDate )->getTimestamp() - DateTime::createFromFormat( DATE_ATOM, $startDate )->getTimestamp();
				if ( $diff <= 0 )
				{
					$this->log()->instance_validation( "4.7.2", "In a 'duration' context the start date must precede the end date", array( 'context' => $id ) );
				}
			}

			/* ---------------------------------------------------------
			 * Validate the entity
			 * ---------------------------------------------------------
			 */

			if ( ! isset( $context['entity'] ) )
			{
				$this->log()->instance_validation( "4.7.3", "An entity element MUST exist in a context", array( 'context' => $id ) );
				continue;
			}

			$entity = $context['entity'];

			if ( ! isset( $entity['identifier'] ) )
			{
				$this->log()->instance_validation( "4.7.3.1", "An entity element in a context MUST contain an identifier", array( 'context' => $id ) );
			}
			else
			{
				$identifier = $entity['identifier'];

				if ( ! isset( $identifier['scheme'] ) )
				{
					$this->log()->instance_validation( "4.7.3.1", "An identifier element in a context MUST include a 'scheme' attribute to identify the namespace", array( 'context' => $id ) );
				}

				if ( ! isset( $identifier['value'] ) )
				{
					$this->log()->instance_validation( "4.7.3.1", "An identifier element in a context MUST include a value", array( 'context' => $id ) );
				}
			}

			/* ---------------------------------------------------------
			 * Validate the segments
			 * ---------------------------------------------------------
			 */

			$validationTypes = array(
				'explicitMember' => 'validateExplicitMembers',
				'member' => 'validateNonDimensionMembers',
				'other' => 'validateOtherComponentTypes',
				'typedMember' => 'validateTypedMembers',
			);

			// A block of data the functions can pass to themselves for cross-function testing
			$data = null;

			if ( isset( $entity[ XBRL_Constants::$xbrliSegment ] ) )
			{
				foreach ( $validationTypes as $segmentType => $functionName )
				{
					// A block of data the functions can pass to themselves for cross-function testing
					// $data = null;

					if ( $segmentType == 'other' )
					{
						$this->validateOtherComponentTypes( $entity[ XBRL_Constants::$xbrliSegment ], $id, $types,  XBRL_Constants::$xbrliSegment, $data );
						continue;
					}

					if ( ! isset( $entity[ XBRL_Constants::$xbrliSegment ][ $segmentType ] ) ) continue;

					$segments = $entity[  XBRL_Constants::$xbrliSegment ][ $segmentType ];

					foreach ( $segments as $segment )
					{
						$this->$functionName( $segment, $id, $types,  XBRL_Constants::$xbrliSegment, $data );
					}

				}
			}

			/* ---------------------------------------------------------
			 * Validate the scenarios
			 * ---------------------------------------------------------
			 */

			// Shouldn't this be just like validating segments?

			if ( isset( $context[ XBRL_Constants::$xbrliScenario ] ) )
			{

				foreach ( $validationTypes as $scenarioType => $functionName )
				{
					// A block of data the functions can pass to themselves for cross-function testing
					// $data = null;

					if ( $scenarioType == 'other' )
					{
						$this->validateOtherComponentTypes( $context[ XBRL_Constants::$xbrliScenario ], $id, $types,  XBRL_Constants::$xbrliScenario, $data );
						continue;
					}

					if ( ! isset( $context[ XBRL_Constants::$xbrliScenario ][ $scenarioType ] ) ) continue;

					$scenarios = $context[ XBRL_Constants::$xbrliScenario ][ $scenarioType ];

					foreach ( $scenarios as $scenario )
					{
						$this->$functionName( $scenario, $id, $types,  XBRL_Constants::$xbrliScenario, $data );
					}
				}
			}

			// Need to check there are no dimensions spread across

		}

		/* ---------------------------------------------------------
		 * Validate the units
		 * ---------------------------------------------------------
		 */

		foreach ( $this->units as $id => $unit )
		{
			/* ---------------------------------------------------------
			 * Validate the ID
			 * ---------------------------------------------------------
			 */
			if ( empty( $id ) ) // Should never happen here because these should be filtered when the context is read
			{
				$this->log()->instance_validation( "4.8.1", "All units must have a valid id", array() );
			}

			// A unit definition can be a single measure in which case the unit is a simple string.
			if ( is_string( $unit ) )
			{
				$this->validateMeasure( $unit, $id, $types );
				continue;
			}

			// Otherwise its an array of components which may be two or more
			// measures or a numerator followed by a denominator

			if ( isset( $unit['measures'] ) && isset( $unit['divide'] ) )
			{
				$this->log()->instance_validation( "4.8.1", "Both a 'measure' and a 'divide' provided.  Should provide one or the other", array( 'unit' => $id ) );
			}

			if ( isset( $unit['measures'] ) )
			{
				$measures = $unit['measures'];
				foreach ( $measures as $measure )
				{
					$this->validateMeasure( $measure, $id, $types );
				}
			}

			if ( isset( $unit['divide'] ) )
			{
				$this->validateDivide( $unit['divide'], $id, $types );
			}
		}

		/* ---------------------------------------------------------
		 * Validate the facts
		 * ---------------------------------------------------------
		 */

		$this->validateFacts( $this->elements, 'xbrl', $types, $prefixes );

		/* ---------------------------------------------------------
		 * Validate footnotes
		 * ---------------------------------------------------------
		 */

		if ( isset( $this->footnotes['arcs'] ) )
		{
			// Build a list of elements with ids
			$ids = array_reduce( $this->elements, function( $ids, $element ) {
				$ids += array_reduce( $element, function( $ids, $fact ) {
					if ( isset( $fact['id'] ) ) $ids[ $fact['id'] ] = $fact;
					return $ids;
				}, array() );
				return $ids;
			}, array() );

			foreach ( $this->footnotes['arcs'] as $id => $labels )
			{
				$fragment = parse_url( $id, PHP_URL_FRAGMENT );
				// Look for an element with this id
				if ( isset( $ids[ $fragment ] ) ) continue;

				$target = "The id does not exist";
				// Look to see if the id is for a context, unit or element
				if ( $this->getContext( $fragment ) )
				{
					$target = "The id references a context";
				}
				else if ( $this->getUnit( $fragment ) )
				{
					$target = "The id references a unit";
				}
				else if ( $this->getElements( $fragment ) )
				{
					$target = "The id references a fact probably in a different extended link";
				}

				$labels = array_reduce( $labels, function( $carry, $item )
				{
					$carry = array_merge( $carry, isset( $item['footnote'] ) ? $item['footnote'] : array() );
					return $carry;
				}, array() );

				$this->log()->instance_validation( "4.11.1.1", "The footnote fact does not exist.",
					array(
						'id' => $fragment,
						'footnotes' => implode( ", ", $labels ),
						'target' => $target,
					)
				);
			}
		}

		/* ---------------------------------------------------------
		 * Validate require elements
		 * ---------------------------------------------------------
		 */

		$this->validateRequiresElementArcs( $types );

		/* ---------------------------------------------------------
		 * Validate essence alias
		 * ---------------------------------------------------------
		 */

		$this->validateEssenceAliasArcs( $types );

		/* ---------------------------------------------------------
		 * Validate calculations
		 * ---------------------------------------------------------
		 */

		$this->validateCalculations( $types );

		/* ---------------------------------------------------------
		 * Validate GeneralSpecial
		 * ---------------------------------------------------------
		 */

		$this->validateGeneralSpecial( $types );

		/* ---------------------------------------------------------
		 * Validate non-dimensional
		 * ---------------------------------------------------------
		 */

		$this->validateNonDimensionalArcRoles( $types, $this->getInstanceTaxonomy() );

		return ! $this->log()->hasInstanceValidationWarning();
	}
1028075
private function preValidationCast()
    {
        $rules = $this->getAttributeRules();

        // Check each dirty attribute.
        foreach ($this->getDirty() as $key => $value) {
            // Get the rules.
            $rules_array = explode('|', array_get($rules, $key, ''));

            // First item is always the cast type.
            $cast = array_get($rules_array, 0, false);

            // Check if the value can be nullable.
            $nullable = in_array('nullable', $rules_array);

            switch ($cast) {
                case 'string':
                    $value = (string) $value;
                    break;
                case 'boolean':
                    $value = (bool) (int) $value;
                    break;
                case 'integer':
                    $value = (int) $value;
                    break;
                case 'numeric':
                    $value = (float) preg_replace('/[^0-9.-]*/', '', $value);
                    break;
            }

            // Value is empty, let's nullify.
            if (empty($value) && $nullable) {
                $value = null;
            }

            $this->attributes[$key] = $value;
        }
    }
647544
public function val()
    {
        $el = count($this) > 1 ? $this->get(0) : $this;
        switch (strtoupper($el->nodeName(false))) {
            case 'TEXTAREA':
                return $el->html();
            case 'INPUT':
                switch (strtoupper($el->attr('type'))) {
                    case 'CHECKBOX':if ($el->attr('checked') === false) {
                            return false;
                        }

                    default:return $el->attr('value');
                }
                return $el->html();
            case 'SELECT': // ???

            default:return false;
        }
    }
644252
public function valid(): bool
    {
        if (!$this->isUsed) {
            $this->call
                ->addIterableEvent($this->callEventFactory->createUsed());

            if ($this->traversable instanceof IteratorAggregate) {
                $this->iterator = $this->traversable->getIterator();
            } else {
                $this->iterator = $this->traversable;
            }

            $this->isUsed = true;
        }

        if ($isValid = $this->iterator->valid()) {
            $this->key = $this->iterator->key();
            $this->value = $this->iterator->current();
        } else {
            $this->key = null;
            $this->value = null;
        }

        if ($this->isConsumed) {
            return $isValid;
        }

        if ($isValid) {
            $this->call->addIterableEvent(
                $this->callEventFactory
                    ->createProduced($this->key, $this->value)
            );
        } else {
            $this->call->setEndEvent($this->callEventFactory->createConsumed());
            $this->isConsumed = true;
        }

        return $isValid;
    }
1092867
public function validate() {

		$result = parent::validate();

		// Confirm that the current attribute has been given a title.

		if($result->isValid() && !$this->Title) {
			$result->addError('"Title" required!');
		}

		// Allow extension customisation.

		$this->extend('validateMediaAttribute', $result);
		return $result;
	}
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']);
        }
    }
275484
public function validate() {

		// check whether a CSRF token was tainted
		
		if($this->enableCsrfToken && !$this->checkCsrfToken()) {

			throw new HtmlFormException('CSRF token mismatch.', HtmlFormException::CSRF_TOKEN_MISMATCH);

		}

		$this->formErrors = [];

		foreach($this->elements as $name => $e) {
			
			if(is_array($e)) {
				foreach($e as $ndx => $elem) {
				    if(!$elem->isValid()) {
                        if (!isset($this->formErrors[$name])) {
                            $this->formErrors[$name] = [];
                        }
                        $this->formErrors[$name][$ndx] = new FormError($elem->getValidationErrorMessage());
                    }
				}
			}

			else if(!$e->isValid()) {
				$this->formErrors[$name] = new FormError($e->getValidationErrorMessage());
			}
		}

		return $this;

	}
1289978
public function validate()
    {
        if (($_FILES) && (isset($_FILES[$this->name]['name']))) {
            $value = $_FILES[$this->name]['name'];
            $size  = $_FILES[$this->name]['size'];
        } else {
            $value = null;
            $size  = null;
        }
        // Check if the element is required
        if (($this->required) && empty($value)) {
            $this->errors[] = 'This field is required.';
        }
        // Check field validators
        if (count($this->validators) > 0) {
            foreach ($this->validators as $validator) {
                if ($validator instanceof \Pop\Validator\ValidatorInterface) {
                    $class =  get_class($validator);
                    if ((null !== $size) &&
                        (('Pop\Validator\LessThanEqual' == $class) || ('Pop\Validator\GreaterThanEqual' == $class) ||
                         ('Pop\Validator\LessThan' == $class) || ('Pop\Validator\GreaterThan' == $class))) {
                        if (!$validator->evaluate($size)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    } else {
                        if (!$validator->evaluate($value)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    }
                } else if (is_callable($validator)) {
                    $result = call_user_func_array($validator, [$value]);
                    if (null !== $result) {
                        $this->errors[] = $result;
                    }
                }
            }
        }
        return (count($this->errors) == 0);
    }
184402
public function valid()
    {

        if ($this->container['created'] === null) {
            return false;
        }
        if ($this->container['name'] === null) {
            return false;
        }
        $allowedValues = $this->getNameAllowableValues();
        if (!in_array($this->container['name'], $allowedValues)) {
            return false;
        }
        if ($this->container['status'] === null) {
            return false;
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!in_array($this->container['status'], $allowedValues)) {
            return false;
        }
        if ($this->container['updated'] === null) {
            return false;
        }
        return true;
    }
704826
protected function validateAttributes()
    {
        if ($this->file === null && count($this->dirsets) === 0 && count($this->filesets) === 0 && count($this->filelists) === 0) {
            throw new BuildException("CopyTask. Specify at least one source - a file, fileset or filelist.");
        }

        if ($this->destFile !== null && $this->destDir !== null) {
            throw new BuildException("Only one of destfile and destdir may be set.");
        }

        if ($this->destFile === null && $this->destDir === null) {
            throw new BuildException("One of destfile or destdir must be set.");
        }

        if ($this->file !== null && $this->file->exists() && $this->file->isDirectory()) {
            throw new BuildException("Use a fileset to copy directories.");
        }

        if ($this->destFile !== null && (count($this->filesets) > 0 || count($this->dirsets) > 0)) {
            throw new BuildException("Cannot concatenate multiple files into a single file.");
        }

        if ($this->destFile !== null) {
            $this->destDir = new PhingFile($this->destFile->getParent());
        }
    }
6257
public function isValid()
    {
        $blnReturn = true;

        $intDynamicCount = $this->getDynamicCount();

        for ($intCount = 0; $intCount <= $intDynamicCount; $intCount ++) {
            $blnReturn = $this->__validate($intCount);

            if (! $blnReturn) {
                break;
            }
        }

        return $blnReturn;
    }
1098226
public function isValid()
    {
        $valid = $this->prefix != '';
        $valid = $valid && $this->startMultiLine != '';
        $valid = $valid && $this->endMultiLine != '';
        $valid = $valid && $this->simpleDirective != '';

        return $valid;
    }
1271088
public function validate()
    {
        foreach ($this as $element) {

            if (
                $element instanceof ValidationAwareInterface ||
                $element instanceof ContainerInterface
            ) {
                $element->validate();
            }
        }
        return $this;
    }
262870
public function validate() {
    if (!in_array($this->mode, ['symlink', 'copy'])) {
      throw new BuildException("mode attribute must be either 'symlink' or 'copy'", $this->location);
    }

    if (empty($this->source) || empty($this->dest)) {
      throw new BuildException("Both the 'source' and 'dest' attributes are required.");
    }
  }
645686
public function validateInput(): bool
    {
        if (!$def = $this->definition) {
            return true;
        }

        $in        = $this->input;
        $out       = $this->output;
        $givenArgs = $errArgs = [];

        foreach ($in->getArgs() as $key => $value) {
            if (\is_int($key)) {
                $givenArgs[$key] = $value;
            } else {
                $errArgs[] = $key;
            }
        }

        if (\count($errArgs) > 0) {
            $out->liteError(\sprintf('Unknown arguments (error: "%s").', \implode(', ', $errArgs)));
            return false;
        }

        $defArgs     = $def->getArguments();
        $missingArgs = \array_filter(\array_keys($defArgs), function ($name, $key) use ($def, $givenArgs) {
            return !\array_key_exists($key, $givenArgs) && $def->argumentIsRequired($name);
        }, \ARRAY_FILTER_USE_BOTH);

        if (\count($missingArgs) > 0) {
            $out->liteError(\sprintf('Not enough arguments (missing: "%s").', \implode(', ', $missingArgs)));
            return false;
        }

        $index = 0;
        $args  = [];

        foreach ($defArgs as $name => $conf) {
            $args[$name] = $givenArgs[$index] ?? $conf['default'];
            $index++;
        }

        $in->setArgs($args);

        // check options
        $opts      = $missingOpts = [];
        $givenOpts = $in->getOptions();
        $defOpts   = $def->getOptions();

        // check unknown options
        if ($unknown = \array_diff_key($givenOpts, $defOpts)) {
            $names = \array_keys($unknown);
            $first = \array_shift($names);

            throw new \InvalidArgumentException(\sprintf(
                'Input option is not exists (unknown: "%s").',
                (isset($first[1]) ? '--' : '-') . $first
            ));
        }

        foreach ($defOpts as $name => $conf) {
            if (!$in->hasLOpt($name)) {
                if (($srt = $conf['shortcut']) && $in->hasSOpt($srt)) {
                    $opts[$name] = $in->sOpt($srt);
                } elseif ($conf['required']) {
                    $missingOpts[] = "--{$name}" . ($srt ? "|-{$srt}" : '');
                }
            }
        }

        if (\count($missingOpts) > 0) {
            $out->liteError(
                \sprintf('Not enough options parameters (missing: "%s").',
                    \implode(', ', $missingOpts))
            );
            return false;
        }

        if ($opts) {
            $in->setLOpts($opts);
        }

        return true;
    }
451294
public function validateNumAssertions()
    {
        $encryptedAssertionNodes = $this->document->getElementsByTagName('EncryptedAssertion');
        $assertionNodes = $this->document->getElementsByTagName('Assertion');

        $valid = $assertionNodes->length + $encryptedAssertionNodes->length == 1;

        if ($this->encrypted) {
            $assertionNodes = $this->decryptedDocument->getElementsByTagName('Assertion');
            $valid = $valid && $assertionNodes->length == 1;
        }

        return $valid;
    }