Check validation and hashing password
@param array $data
@return boolean|array errors
559245
protected function _modify(array $data = null)
	{
		if ($this->is_valid()) {
			if (isset($data['password'])) {
				$this->password = Auth::hash($data['password']);
			}
			return $this->save();
		}

		return $this->errors->full_messages();
	}
823375
protected function validateAnyValues(array $data)
    {
        $errors = [];

        foreach (array_diff_key($data, $this->properties) as $key => $value) {
            if (isset($this->properties[':any_name:'])) {
                if ($value === null) {
                    if ($this->properties[':any_name:']->isRequired()) {
                        $errors[$key] = [ Error::MISSING_VALUE ];
                    }
                    continue;
                }
                $result = $this->properties[':any_name:']->validate($value);
                if ($result instanceof Error) {
                    $errors[$key] = $result->unwrap();
                }
            } else {
                $errors[$key] = [ Error::UNEXPECTED_KEY ];
            }
        }

        return empty($errors) ? Ok::unit() : Error::unit($errors);
    }
981768
protected function validateMappedValues(array $data)
    {
        $errors = [];

        foreach (array_diff_key($this->properties, [ ':any_name:' => 1 ]) as $key => $property) {
            $result = $this->selectValue($property, $data);
            if ($result instanceof Ok) {
                $value = $result->unwrap();
                if ($value === null) {
                    continue;
                }
                $result = $property->validate($value);
            }
            if ($result instanceof Error) {
                $errors[$key] = $result->unwrap();
            }
        }

        return empty($errors) ? Ok::unit() : Error::unit($errors);
    }
385913
protected function validateDataFromCache($data): bool
    {
        if (!\is_array($data)) {
            return false;
        }

        foreach (['value', 'ttl'] as $missing) {
            if (!\array_key_exists($missing, $data)) {
                return false;
            }
        }

        return true;
    }
598774
public static function recover($data) {
    if (!Tilmeld::$config['pw_recovery']) {
      return [
        'result' => false,
        'message' => 'Account recovery is not allowed.'
      ];
    }

    $user = User::factory($data['username']);

    if (!isset($user->guid)
        || !isset($user->recoverSecret)
        || $data['secret'] !== $user->recoverSecret
        || strtotime(
            '+'.Tilmeld::$config['pw_recovery_time_limit'],
            $user->recoverSecretTime
        ) < time()
      ) {
      return [
        'result' => false,
        'message' => 'The secret code does not match.'
      ];
    }

    if (empty($data['password'])) {
      return ['result' => false, 'message' => 'Password cannot be empty.'];
    }

    $user->password($data['password']);
    unset($user->recoverSecret);
    unset($user->recoverSecretTime);
    if ($user->saveSkipAC()) {
      return [
        'result' => true,
        'message' => 'Your password has been reset. You can now log in using '.
          'your new password.'
      ];
    } else {
      return ['result' => false, 'message' => 'Error saving new password.'];
    }
  }
489626
public function create(array $data)
    {
        try
        {
            if ( $this->validator->with($data)->passes() )
            {
                $this->users->create($data,$data['activate']);
                return true;
            }
        }
        catch (LoginRequiredException $e)
        {
            $this->validator->add('LoginRequiredException',$e->getMessage());
        }
        catch (PasswordRequiredException $e)
        {
            $this->validator->add('PasswordRequiredException',$e->getMessage());
        }
        catch (UserExistsException $e)
        {
            $this->validator->add('UserExistsException',$e->getMessage());
        }

        return false;
    }
293703
final public function validate($data)
    {
        if ($this->_walk && (is_array($data) || is_object($data))) {
            $arr = (array)$data;

            foreach ($arr as $value) {
                if ($this->validate($value) ===  false) {
                    return false;
                }
            }
        } else {
            $context = $this->_chain->getContext();
            $context->data = $data;

            $result = $this->_chain->run('validate', $context);

            if ($result ===  false) {
                return false;
            }
        }

        return true;
    }
24494
public function isValid($data) {
        if (!is_array($data)) {
            throw new Zend_Form_Exception(__METHOD__ . ' expects an array');
        }

        $this->_incrementArray($data);
        return parent::isValid($data);
    }
416585
protected final function validateNewData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			return $this->validateData($this->rules, $data);
		}

		return true;
	}
941528
public function getIsAllValuesValid(array $data)
    {
        foreach($data as $value)
        {
            if(!$this->getIsValidValue($value))
            {
                return false;
            }
        }
        return true;
    }
76407
private function validateNestedKeys($data)
    {
        $ex = new ValidationException(ValidationException::VALIDATION_FAILED, [$this->attribute]);
        $messages = $this->getKeyValidationMessages();
        $keyValidators = $this->getKeyValidators();
        $errors = [];

        foreach ($keyValidators as $key => $validators) {
            $keyValue = $this->arr($data)->keyNested($key);
            if ($this->isString($validators)) {
                $validators = explode(',', $validators);
            }

            // Do not validate if attribute value is not required and empty value is given
            // 'empty' function is not suitable for this check here
            if (!in_array('required', $validators) && (is_null($keyValue) || $keyValue === '')) {
                continue;
            }

            foreach ($validators as $validator) {
                try {
                    $this->applyValidator($validator, $key, $keyValue, isset($messages[$key]) ? $messages[$key] : []);
                } catch (ValidationException $e) {
                    foreach ($e as $key => $error) {
                        $errors[$this->attr() . '.' . $key] = $error;
                    }
                }
            }
        }

        if (count($errors)) {
            foreach ($errors as $key => $msg) {
                $ex->addError($key, $msg);
            }
            throw $ex;
        }
    }
1151045
protected function isMacValid($data, $bytes)
    {
        $calculated = hash_hmac(
            'sha384', $this->mac($data['iv'], $data['value']), $bytes, true
        );

        return hash_equals(
            hash_hmac('sha384', $data['hash_mac'], $bytes, true), $calculated
        );
    }
32492
protected function beforeValidation($data)
  {
    if ($this->before_validation) {
      $data = call_user_func_array($this->before_validation, array($data, $this));
    }

    return $data;
  }
1279901
public function validation($data, $files) {
        $user = $this->_customdata;

        $errors = parent::validation($data, $files);

        // Ignore submitted username.
        if ($data['password'] !== $data['password2']) {
            $errors['password'] = get_string('passwordsdiffer');
            $errors['password2'] = get_string('passwordsdiffer');
            return $errors;
        }

        $errmsg = ''; // Prevents eclipse warnings.
        if (!check_password_policy($data['password'], $errmsg)) {
            $errors['password'] = $errmsg;
            $errors['password2'] = $errmsg;
            return $errors;
        }

        if (user_is_previously_used_password($user->id, $data['password'])) {
            $errors['password'] = get_string('errorpasswordreused', 'core_auth');
            $errors['password2'] = get_string('errorpasswordreused', 'core_auth');
        }

        return $errors;
    }
1213855
public function validate(array $data = null)
    {
        $data = $data ?: $this->getInput();

        $this->validation = $this->validator->make($data, $this->rules(), $this->messages());

        if ($this->validation->fails())
        {
            $this->failed();

            return false;
        }

        return true;
    }
561681
public function validate(array $data) : bool
    {
        $passed = true;
        $this->invalidFields = [];
        $rules = $this->getRules();
        foreach ($rules as $validation => $fields) {
            foreach ($fields as $key => $value) {
                $field = $this->getFieldInfo($key, $value);
                $validationInstance = $this->getValidation($validation);
                $validationStatus = $validationInstance->run($field, $data);
                $passed = $passed && $validationStatus;
                $this->invalidFields = array_merge_recursive(
                        $this->invalidFields, $validationInstance->getMessages()
                );
            }
        }
        return $passed;
    }
1368519
public function validate(array $data)
    {
        $validator = $this->getValidator();
        if (!$validator->count()) {
            $method = new ReflectionMethod($this, 'validator');
            if ($method->getDeclaringClass()->getName() !== __CLASS__) {
                $validator = $this->validator();
            }
        }
        $this->_errors = $validator->errors($data);

        return count($this->_errors) === 0;
    }