Validate the required attributes.

@return bool

@throws AdldapException
171003
public function validateRequired()
    {
        parent::validateRequired();

        if (!is_array($this->getAttribute('container'))) {
            $message = 'Container attribute must be an array.';

            throw new AdldapException($message);
        }

        return true;
    }
174796
public function isValid()
    {
        if (!$rules = $this->rules()) {
            return true;
        }

        $attributes = $this->getAttributes();

        // Verify attributes that are hashed and that have not changed
        // those doesn't need to be validated.
        foreach ($this->hashedAttributes as $hashedAttr) {
            if (isset($this->original[$hashedAttr]) && $this->$hashedAttr == $this->original[$hashedAttr]) {
                unset($rules[$hashedAttr]);
            }
        }

        // Creates validator with attributes and the rules of the object
        $validator = app(ValidationFactory::class)->make($attributes, $rules, $this->messages());

        // Validate and attach errors
        if ($hasErrors = $validator->fails()) {
            $this->errors = $validator->errors();
        }

        return !$hasErrors;
    }
259798
protected function validate()
    {
        /** @var Parameter[] $missingItems */
        $missingItems = \array_filter($this->_options + $this->_arguments, function ($item) {
            /* @var Parameter $item */
            return $item->required() && \in_array($this->_values[$item->attributeName()], [null, []]);
        });

        foreach ($missingItems as $item) {
            list($name, $label) = [$item->name(), 'Argument'];
            if ($item instanceof Option) {
                list($name, $label) = [$item->long(), 'Option'];
            }

            throw new RuntimeException(
                \sprintf('%s "%s" is required', $label, $name)
            );
        }
    }
32211
public function validate() {
        $validator = \validator(
                $this->attributes, $this->overrideNormalRules(static::$rules), static::$messages
        );

        $validator->addExtensions($this->overrideCustomRules(static::$customRules));

        foreach ($this->overrideComplexRules(static::$complexRules) as $field => $validation) {
            $rules = $validation["rules"];
            $check = $validation["check"];
            $validator->sometimes($field, $rules, $check);
        }

        if ($validator->passes()) {
            return true;
        }
        $this->setErrors($validator->messages());
        return false;
    }
435419
public function validate(): void
    {
        $required = [
            'app_root',
            'app_name',
            'default_filesystem',
            'environment',
            'default_branch',
            'default_database_adapter',
            'default_database_importexport_adapter',
            'default_dir_mode',
            'default_file_mode',
            'platform',
            'relative_document_root',
            'repo_url',
        ];
        $missingRequired = [];
        foreach ($required as $name) {
            if (empty($this->config[$name])) {
                $missingRequired[] = $name;
            }
        }
        if ($missingRequired) {
            throw new Exception\RuntimeException(
                'Missing required values for top level configuration key(s): "' . implode('", "', $missingRequired)
                . '"'
            );
        }

        if (!in_array(
            $this->config['file_layout'],
            [
                FileLayoutInterface::STRATEGY_BLUE_GREEN,
                FileLayoutInterface::STRATEGY_DEFAULT
            ]
        )) {
            throw new Exception\DomainException("Invalid file layout \"{$this->config['file_layout']}\".");
        }

        $this->buildConfig->validate();
        $this->deployConfig->validate();
        $this->snapshotConfig->validate();
        $this->skeletonConfig->validate();
    }
709090
protected function validateArguments()
    {
        if ($this->getIsAnonymousBind()) {
            return;
        }
        if (empty($this->properties['username']) || empty($this->properties['password'])) {
            throw new LdapBindException("You must specify a username and password.");
        }
    }
797483
function validate()
    {
        $errors = array();

        BagIt_validateExists($this->bagitFile, $errors);
        BagIt_validateExists($this->getDataDirectory(), $errors);
        $this->manifest->validate($errors);

        $this->bagErrors = $errors;
        return $this->bagErrors;
    }
986507
protected function ValidateStepData()
    {
        $bContinue = $this->ValidateUser($this->GetUserData());

        // which address do we need to validate? if $this->GetShipToBillingAddress() != 1 then we need to validate both..
        // otherwise one will do...

        if ('1' != $this->GetShipToBillingAddress()) {
            $bContinue = $this->ValidateShippingAddress($this->GetShippingAddressData()) && $bContinue;
            $bContinue = $this->ValidateBillingAddress($this->GetBillingAddressData()) && $bContinue;
        } else {
            switch ($this->AddressUsedAsPrimaryAddress()) {
                case TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING:
                    $bContinue = $this->ValidateShippingAddress($this->GetShippingAddressData()) && $bContinue;
                    break;

                default:
                case TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING:
                    $bContinue = $this->ValidateBillingAddress($this->GetBillingAddressData()) && $bContinue;
                    break;
            }
        }

        return $bContinue;
    }
910636
public function validate()
	{
		$validity = Rules::validate($this->attributes, $this->getRules());

		if ($validity === true)
		{
			return true;
		}

		$this->setErrors($validity);
		return false;
	}
432637
public function validate() {
        global $DB;
        $params = array_keys($this->params);
        $method = ($this->method == BADGE_CRITERIA_AGGREGATION_ALL);
        $singleparam = (count($params) == 1);

        foreach ($params as $param) {
            // Perform check if there only one parameter with any type of aggregation,
            // Or there are more than one parameter with aggregation ALL.
            if (($singleparam || $method) && !$DB->record_exists('cohort', array('id' => $param))) {
                return array(false, get_string('error:invalidparamcohort', 'badges'));
            }
        }

        return array(true, '');
    }
155192
public function isValid() : bool
   {

      if ( $this->_support->hasAttribute( $this->_requiredAttributeName ) )
      {
         return true;
      }

      return $this->_support->hasAttribute( $this->_altAttributeName );

   }
1356513
protected function validateRoleUser()
    {
        $field = 'role_id';
        $value = $this->getSubmitted($field);

        if (empty($value)) {
            return null;
        }

        $label = $this->translation->text('Role');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $role = $this->role->get($value);

        if (empty($role)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }
834369
protected function validate()
    {
        $rules = $this->mergeRules();

        if ( empty($rules) ) return true;

        $data = $this->attributes;

        $validator = Validator::make($data, $rules);
        $success = $validator->passes();

        if ( $success )
        {
            if ( $this->validationErrors->count() > 0 )
            {
                $this->validationErrors = new MessageBag;
            }
        } else
        {
            $this->validationErrors = $validator->messages();
            throw new ValidationErrorException($validator->messages());
        }

        $this->valid = true;

        return $success;
    }
102568
private function validateAttributes()
    {
        if (null === $this->apiUrl) {
            throw new BuildException('Wiki apiUrl is required');
        }

        if (null === $this->id && null === $this->title) {
            throw new BuildException('Wiki page id or title is required');
        }
    }
517852
public function validateOrFail()
    {
        // Validate data
        $passed = $this->validate();

        // If validation failed,
        // we'll throw an exception
        if (! $passed) {
            throw new ValidationException($this->validator, $this->getErrorCodes());
        }

        return true;
    }
1084607
public function isValid()
    {
        $value = $this->field->getValue();

        if (is_array($value) || is_object($value)) {
            throw new \Exception("This validator only works on scalar types!");
        }

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        $len = strlen($value);

        // shorter then min length
        if ($len < $this->getMinLength()) {
            return false;
        }

        // bigger then the given length
        if ($this->getMaxLength() > 0 && $len > $this->getMaxLength()) {
            return false;
        }

        return true;
    }
383438
public function validateAllowEmpty()
    {
        $val = $this->val();

        if (($val === null || $val === '') && !$this->allowEmpty()) {
            return false;
        } else {
            return true;
        }
    }