Validate a new resource.

@param array $data

@return string[] An array of validation errors.
333671
protected static function checkNew(array $data)
    {
        $errors = [];
        if ($missing = array_diff(static::getRequired(), array_keys($data))) {
            $errors[] = 'Missing: ' . implode(', ', $missing);
        }
        foreach ($data as $key => $value) {
            $errors += static::checkProperty($key, $value);
        }
        return $errors;
    }
266737
public static function getCreateErrors(array $data, array $errors = [])
    {
        if (!isset($data['singular']) || empty($data['singular'])) {
            $errors['singular'] = 'Singular is required';
        }

        if (!isset($data['plural']) || empty($data['plural'])) {
            $errors['plural'] = 'Plural is required';
        }

        if (!isset($data['name']) || empty($data['name'])) {
            $errors['name'] = 'Keyword is required';
        }

        if (!isset($data['fields']) || empty($data['fields'])) {
            $errors['fields'] = 'Fields is required';
        }

        if (isset($data['name'])) {
            $exists = false;
            try {
                $exists = Schema::i($data['name'])->getAll();
            } catch (Exception $e) {
            }

            if ($exists) {
                $errors['name'] = 'Schema already exists';
            }
        }

        return self::getOptionalErrors($data, $errors);
    }
380120
public function validate($data)
    {
        $errors = new \Concrete\Core\Error\Error();

        /**
         * if ('Oliver' !== $data['name']) {
         *     $errors['name'] = "You input the incorrect name.";
         * }.
         */
        if ($errors->has()) {
            return $errors;
        }

        return true;
    }
1091187
public function validate(array $data, $rules = null, $custom = false)
    {
        if (!$custom) {
            $rules = $this->rules($rules);
        }

        return $this->validator->make($data, $rules);
    }
1159215
public function validate($data) {
        // allow paramtype to be a custom regex if it is the form of /pattern/
        if (preg_match('#^/.*/$#', $this->paramtype)) {
            if (preg_match($this->paramtype, $data)) {
                return true;
            } else {
                return get_string('validateerror', 'admin');
            }

        } else if ($this->paramtype === PARAM_RAW) {
            return true;

        } else {
            $cleaned = clean_param($data, $this->paramtype);
            if ("$data" === "$cleaned") { // implicit conversion to string is needed to do exact comparison
                return true;
            } else {
                return get_string('validateerror', 'admin');
            }
        }
    }
1095125
public function instance_form_validation(array $data, array $files) : array {
        $errors = [];
        $elementname = $this->get_form_element_name();
        if ($this->get_field()->get_configdata_property('uniquevalues') == 1) {
            $value = $data[$elementname];
            if (!$this->is_empty($value) && !$this->is_unique($value)) {
                $errors[$elementname] = get_string('erroruniquevalues', 'core_customfield');
            }
        }
        return $errors;
    }
1237307
protected function ensureAllInRules(array $data)
    {
        $rules = $this->rules();

        $invalid = array_diff_key($data, $rules);

        if (!empty($invalid)) {
            throw new ValidationFailed(new MessageBag([
                'Invalid keys found in request.',
            ]));
        }

        return $this;
    }
430754
public static function validate(array $data, array $rules = [], array $messages = []): array
    {
        $errors = [];

        foreach ($rules as $name => $field_rules) {
            if (isset($data[$name])) {
                $field_value = $data[$name];

                $found_err = self::validateFiled($data, $field_value, self::normalizeRules($field_rules), $messages[$name] ?? []);

                if(\is_array($found_err)){
                    $errors[$name] = $found_err;
                }
            }
        }

        return $errors;
    }
1173276
protected function getValidator($data = null)
    {
        if (!$this->validator) {
            if ($data) {
                // Validate without key
                if ($this->lastKey === '') {
                    $data = ['' => $data];
                }

                $this->options['data'] = $data;
            }

            $this->validator = $this->wei->validate($this->options);
        }

        return $this->validator;
    }
73044
public static function valid($data)
    {
        $rules = [
            'body' => 'required|min:3',
            'post_id' => 'required|min:1|integer|exists:forum_posts,id',
            'author_id' => 'required|min:1|integer|exists:users,id'
        ];
        $validator = Validator::make($data, $rules);

        if ($validator->passes()) {
            return true;
        }
        return false;
    }
695265
public function validation($data, $files) {
        $errors = [];
        if (isset($data['purgeselectedcaches']) && empty(array_filter($data['purgeselectedoptions']))) {
            $errors['purgeselectedoptions'] = get_string('purgecachesnoneselected', 'admin');
        }
        return $errors;
    }
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;
	}
733952
protected function validate(array $data = array())
    {
        $id = auth()->user()->id;
        if (empty($data)) {
            return false;
        }
        if ((int) array_get($data, 'secondary_user_id') !== $id) {
            return false;
        }

        $primary = array_get($data, 'primary_user_id');
        if ($primary === null) {
            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;
        }
    }
850032
public function validator(array $data)
    {
        $validationRules = [
            'name'       => 'required|max:255',
            'first_name' => 'required',
            'last_name'  => 'required',
            'email'      => 'required|email|max:255|unique:user',
            'username'   => 'min:6|unique:user,username|regex:/^\S*$/u|nullable'
        ];

        $loginAttribute = strtolower(config('df.login_attribute', 'email'));
        if ($loginAttribute === 'username') {
            $validationRules['username'] = str_replace('|nullable', '|required', $validationRules['username']);
        }

        /** @var \DreamFactory\Core\User\Services\User $userService */
        $userService = ServiceManager::getService('user');
        if (empty($userService->openRegEmailServiceId)) {
            $validationRules['password'] = 'required|confirmed|min:6';
        }

        return Validator::make($data, $validationRules);
    }
1372806
public function validates($data = null)
    {
        $this->errors = array();

        // Get data if it wasn't passed
        if ($data === null) {
            $data = $this->data();
        }

        foreach (static::$_validates as $field => $validations) {
            Validations::run($this, $field, $validations);
        }

        return count($this->errors) == 0;
    }
992886
protected final function validateUpdateData(array $data = null) {
		if ($data === null && isset($this->_formData)) {
			$data = $this->_formData;
		}
		if ($this->rules) {
			$newRules = [];
			foreach ($data as $key => $v) {
				if (isset($this->rules[ $key ])) {
					$newRules[ $key ] = $this->rules[ $key ];
				}
			}
			if ($newRules) {
				return $this->validateData($newRules, $data);
			}
		}

		return true;
	}