Internal function to ensure, that all required attributes are available.

@param array $spec

@throws MissingAttributeException
769375
protected function ensureRequiredAttributes(array $spec = [])
    {
        if (! isset($spec['attributes'])) {
            throw new MissingAttributeException(
                sprintf('The attribute "attributes" is not defined, but required.')
            );
        }

        $required = ['type', 'name'];
        foreach ($required as $key) {
            if (! isset($spec['attributes'][$key])) {
                throw new MissingAttributeException(
                    sprintf('The attribute "%s" is not defined, but required.', $key)
                );
            }
        }
    }
159562
public function setRequired($required) {
		if(!empty($required))
			$this->validation[] = new Validation\Required;
		$this->_attributes["required"] = "";	
	}
917130
public void addAttribute(AttributeSpecification specification) {
		synchronized (this.attributes) {
			if (!this.attributes.contains(specification)) {
				this.attributes.add(specification);

				if (this.sentAttrSpecifications) {
					this.announceAttributes();
				}
			}
		}
	}
1083994
def enforce_required_fields(self, attrs):
        
        if self.instance is not None:
            return

        missing = {
            field_name: self.missing_message
            for field_name in self.fields
            if field_name not in attrs
        }
        if missing:
            raise ValidationError(missing)
569357
protected function configureErrors(ErrorAwareInterface $element, array $spec = [])
    {
        if (isset($spec['errors']) && is_array($spec['errors'])) {
            $element->withErrors($spec['errors']);
        }

        return $element;
    }
620800
public function validateRequired($only = [])
    {
        if (count($only) > 0) {
            return $this->validateSpecific($only);
        }

        /*
         * Go through each required attribute
         * and make sure they're not null
         */
        foreach ($this->required as $required) {
            if ($this->getAttribute($required) === null) {
                throw new AdldapException(sprintf($this->messages['required'], $required));
            }
        }

        return true;
    }
459605
protected function checkRequiredAttributes()
    {
        foreach ($this->getRequired() as $attribute) {
            if (is_null($this->get($attribute))) {
                throw new InvalidArgumentException(sprintf('"%s" cannot be empty.', $attribute));
            }
        }
    }
272992
static function checkRequiredParametersAreSet(array $given, array $required)
    {
        foreach ($required as $key) {
            if (empty($given[$key])) {
                throw new MissingRequiredParameterException(
                        "Missing required parameter '$key'"
                );
            }
        }
    }
72750
protected function checkAttribute(AttributeInterface $attribute)
    {
        if (!$this->getFamily()->hasAttribute($attribute->getCode())) {
            throw new MissingAttributeException(
                "Attribute {$attribute->getCode()} doesn't exists in family {$this->getFamilyCode()}"
            );
        }
        if ($attribute->getFamily() !== $this->getFamily()) {
            $m = "Attribute {$attribute->getCode()} (from family '{$attribute->getFamily()->getCode()}') doesn't ";
            $m .= "belong to this family ('{$this->getFamilyCode()}')";
            throw new MissingAttributeException($m);
        }
    }
841403
public function setValidation($validation)
    {
        /*If a single validation class is provided, an array is created in order to reuse the same logic.*/
        if (!is_array($validation)) {
            $validation = array($validation);
        }

        foreach ($validation as $object) {
            /*Ensures $object contains a existing concrete validation class.*/
            if ($object instanceof Validation) {
                $this->validation[] = $object;

                if ($object instanceof Validation\Required) {
                    $this->attributes["required"] = "";
                }
            }
        }
    }
1022280
public function group($spec)
    {
        if (!is_array($spec)) {
            $spec = array($spec);
        }

        foreach ($spec as $val) {
            if (preg_match('/\(.*\)/', (string) $val)) {
                $val = new Zend_Db_Expr($val);
            }
            $this->_parts[self::GROUP][] = $val;
        }

        return $this;
    }
1144785
private void handleFeatureIncludes(SpecInfo spec, IncludeExcludeCriteria criteria) {
    if (criteria.isEmpty()) return;

    for (FeatureInfo feature : spec.getAllFeatures())
      if (hasAnyAnnotation(feature.getFeatureMethod(), criteria.annotations))
        feature.setExcluded(false);
  }
1087134
public function validateRequiredWithout($attribute, $value, $parameters)
    {
        if ($this->anyFailingRequired($parameters)) {
            return $this->validateRequired($attribute, $value);
        }

        return true;
    }
224390
private function setPatternProperties($specification)
    {
        if (!is_array($specification)) {
            throw new UnspecifiedValidatorException(
                'The validator Properties is being initialized with an invalid '
                . self::PROPERTIES_INDEX
                . ' parameter'
            );
        }
        foreach ($specification as $key => $item) {
            $this->patternProperties[$key] = $this->checkIfAnnotationAndReturnObject($item);
        }
    }
99733
public static function validates($attr, $validation) 
    {
        $cls = get_called_class();

        if (!array_key_exists($cls, self::$_validations)) {
            self::$_validations[$cls] = array();
        }

        if (!array_key_exists($attr, self::$_validations[$cls])) {
            self::$_validations[$cls][$attr] = array();
        }

        array_push(self::$_validations[$cls][$attr], $validation);
    }
630627
public static function checkAttributes(array $result)
    {
        $expectedAttributes = [
            self::ON_PEP_LIST_KEY,
            self::ON_WATCH_LIST_KEY,
            self::ON_WATCH_LIST_KEY,
        ];
        $providedAttributes = array_keys($result);
        $missingAttr = array_diff($expectedAttributes, $providedAttributes);

        // Throw an error if any expected attribute is missing.
        if (!empty($missingAttr)) {
            throw new AmlException('Missing attributes from the result: ' . implode(',', $missingAttr), 106);
        }
    }
863432
protected function checkRequirements()
    {
        $required_properties = array('_buildFile');
        foreach ($required_properties as $required_property) {
            if (empty($this->$required_property)) {
                throw new \BuildException(
                    "Missing required property '" . $required_property . "'."
                );
            }
        }
    }