@param \Illuminate\Http\Request $request
@param ModelConfigurationInterface $model

@throws ValidationException
176684
public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $model = null)
    {
        if (($content = $this->getContent()) instanceof FormInterface) {
            $content->validateForm($request, $model);
        }
    }
218310
public function validate(EntityInterface $entity)
    {
        if (!$entity instanceof EmailConfiguration) {
            throw new Exception(
                sprintf('The Entity to validate must be an instance of %s', EmailConfiguration::class)
            );
        }

        $this->validateEmailSender($entity->getEmailSender());
        $this->validateEmailSenderName($entity->getEmailSenderName());
        $this->validateEmailSubjectPrefix($entity->getEmailSubjectPrefix());
        $this->validateEmailBodySignature($entity->getEmailBodySignature());

        $errors = $this->getErrors();

        return empty($errors);
    }
533344
protected function invalid($request, ValidationException $e)
    {
        $url = $e->redirectTo ?? url()->previous();

        return redirect($url)
            ->withInput($request->except($this->dontFlash))
            ->withErrors($e->errors(), $e->errorBag);
    }
926593
public function validateValidatorConfiguration($validatorConfiguration)
    {
        $validationErrors = array();

        foreach ($validatorConfiguration as $validatorIdentifier => $constraints) {
            if ($validatorIdentifier !== 'FloatValueValidator') {
                $validationErrors[] = new ValidationError(
                    "Validator '%validator%' is unknown",
                    null,
                    array(
                        '%validator%' => $validatorIdentifier,
                    ),
                    "[$validatorIdentifier]"
                );

                continue;
            }

            foreach ($constraints as $name => $value) {
                switch ($name) {
                    case 'minFloatValue':
                    case 'maxFloatValue':
                        if ($value !== null && !is_numeric($value)) {
                            $validationErrors[] = new ValidationError(
                                "Validator parameter '%parameter%' value must be of numeric type",
                                null,
                                array(
                                    '%parameter%' => $name,
                                ),
                                "[$validatorIdentifier][$name]"
                            );
                        }
                        break;
                    default:
                        $validationErrors[] = new ValidationError(
                            "Validator parameter '%parameter%' is unknown",
                            null,
                            array(
                                '%parameter%' => $name,
                            ),
                            "[$validatorIdentifier][$name]"
                        );
                }
            }
        }

        return $validationErrors;
    }
27562
protected function throwValidationException(Request $request, $validator)
    {
        throw new ResourceException($validator->errors()->first(), $validator->errors());
//        throw new ValidationException($validator, $this->buildFailedValidationResponse(
//            $request, $this->formatValidationErrors($validator)
//        ));
    }
781611
public function apply(Request $request, $configurations)
    {
        if (\is_object($configurations)) {
            $configurations = [$configurations];
        }

        foreach ($configurations as $configuration) {
            $this->applyConverter($request, $configuration);
        }
    }
573955
public function validateForm(InputRequest $request, $domain=null) {
		if( !$this->validateCurrent($request) ) {
			throw new UserException(self::ERROR_INVALIDTOKEN, $domain);
		}
	}
501662
protected function validateRequest(Request $request)
    {
        $validationErrors = array();

        if (strlen($request->getApiMethod()) == 0)
        {
            $validationErrors[] = 'Request api method is empty';
        }

        if (strlen($request->getEndPoint()) == 0 && strlen($request->getEndPointGroup()) === 0)
        {
            $validationErrors[] = 'Request end point is empty and request end point group is empty. Set one of them.';
        }

        if (strlen($request->getEndPoint()) > 0 && strlen($request->getEndPointGroup()) > 0)
        {
            $validationErrors[] = 'Request end point was set and request end point group was set. Set only one of them.';
        }

        if (count($request->getRequestFields()) === 0)
        {
            $validationErrors[] = 'Request data is empty';
        }

        if (!Validator::validateByRule($request->getGatewayUrl(), Validator::URL, false))
        {
            $validationErrors[] = 'Gateway url does not valid in Request';
        }

        if (!empty($validationErrors))
        {
            throw new ValidationException("Some Request fields are invalid:\n" .
                                          implode(";\n", $validationErrors));
        }
    }
833649
protected function throwValidationException(Request $request, $validator)
    {
        throw new ValidationException($validator, $this->buildFailedValidationResponse(
            $request, $this->formatValidationErrors($validator)
        ));
    }
169994
public function render(ModelConfigurationInterface $model, $content, $title = null)
    {
        if ($content instanceof RedirectResponse) {
            return $content;
        }

        if ($content instanceof Renderable) {
            $content = $content->render();
        }

        if (is_null($title)) {
            $title = $model->getTitle();
        }

        return $this->admin->template()->view('_layout.inner')
            ->with('title', $title)
            ->with('content', $content)
            ->with('breadcrumbKey', $this->parentBreadcrumb);
    }
189306
public function validate() {
		parent::validate();

		if ($this->getName() === null) {
			throw new ValidationException("'name' can't be null", 'name', $this);
		}
		if ($this->getType() === null) {
			throw new ValidationException("'type' can't be null", 'type', $this);
		}
	}
467314
public function validate($model, $validators = null)
    {
        if (isset($validators) && is_array($validators)) {
            $validation = $this->validateArray($model, $validators);
        } else {
            $validation = $this->validateModel($model);
        }
        if ($validation) {
            $errors = $validation->validate($model);
            if (count($errors)) {
                throw new ValidationException($errors);
            }
        }
    }
550183
public function censor(Request $request, $censorKey, $attributes, Model $model = null)
	{
		$censor = $this->getCensorFactory()->make($censorKey, $attributes, $model)->data($request->all());
		$validator = $censor->validator();
		return $validator->fails() ? $this->throwValidationException($request, $validator) : $censor->validData();
	}
1284518
public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null)
    {
        if (! $this->validModelConfiguration($modelConfiguration)) {
            return false;
        }

        $model = $this->getModel();
        $loaded = $model->exists;

        if ($this->getModelConfiguration()->fireEvent($loaded ? 'updating' : 'creating', true, $model) === false) {
            return false;
        }

        if ($this->getModelConfiguration()->fireEvent('saving', true, $model) === false) {
            return false;
        }

        parent::save($request);
        $this->saveBelongsToRelations($model);

        $model->save();

        $this->saveHasOneRelations($model);

        parent::afterSave($request);

        $this->getModelConfiguration()->fireEvent($loaded ? 'updated' : 'created', false, $model);
        $this->getModelConfiguration()->fireEvent('saved', false, $model);

        return true;
    }
496112
private function throwExceptionIfErrors(ConstraintViolationListInterface $errors): void
    {
        if (0 === $errors->count()) {
            return;
        }
        throw ValidationException::create($errors, $this->dataObject);
    }
162734
public static <T> void validate(Request<T> request) throws ValidationConstraintViolationException {
		if (request != null) {
			Class<?> clazz = request.getClass();
			List<ConstraintViolation> leafs = new LinkedList<ConstraintViolation>();

			Field[] fields = clazz.getDeclaredFields();
			for (Field field : fields) {
				if (null != field.getAnnotation(Required.class)) {

					field.setAccessible(true);
					Object value = null;
					try {
						value = field.get(request);
					} catch (Exception e) {
						// not cool...
						throw new ValidationConstraintViolationException(e);
					}

					if (value == null || value instanceof String && ((String) value).isEmpty()) {
						ConstraintViolation violation = ConstraintViolation.newConstraintViolation("@" + Required.class.getSimpleName(), field);
						leafs.add(violation);
					}
				}
			}

			if (!leafs.isEmpty()) {
				throw new ValidationConstraintViolationException(preMessage, leafs);
			}
		}
	}
920059
protected function getConfiguration(Request $request = null)
    {
        if (!$this->configuration) {
            if (!$request) {
                throw new \RuntimeException('The first time getConfiguration() is called, you must pass a Request.');
            }

            $this->configuration = new Configuration($request);
            $this->configure($request, $this->configuration);
            $this->configuration->validate();
        }

        return $this->configuration;
    }