leap.core.validation.Validation.errors()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中leap.core.validation.Validation.errors()方法的一些代码示例,展示了Validation.errors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validation.errors()方法的具体详情如下:
包路径:leap.core.validation.Validation
类名称:Validation
方法名:errors

Validation.errors介绍

暂无

代码示例

代码示例来源:origin: org.leapframework/leap-orm

@Override
public Errors validate(EntityWrapper entity, Iterable<String> fields) {
  Validation validation = validationManager.createValidation();
  validate(entity, validation, 1, fields);
  return validation.errors();
}

代码示例来源:origin: org.leapframework/leap-orm

@Override
public Errors validate(EntityMapping em, Object entity, int maxErrors, Iterable<String> fields) {
  Validation validation = validationManager.createValidation();
  entityValidator.validate(EntityWrapper.wrap(ormContext, em, entity), validation, maxErrors, fields);
  return validation.errors();
}

代码示例来源:origin: org.leapframework/leap-core

@Override
public void validate(String name, Object bean) throws ValidationException {
  Validation validation = validationManager.createValidation();
  if(!validate(name, bean, validation, 1)) {
    throw new ValidationException(validation.errors());
  }
}

代码示例来源:origin: org.leapframework/leap-core

@Override
public boolean stateValidate(String name, Object bean) {
  Validation v = createNewValidation(name);
  
  if(!v.stateValidate(bean)){
    addErrors(v.errors());
    return false;
  }
  
  return true;
}

代码示例来源:origin: org.leapframework/leap-websecurity

@Override
  public boolean resolveCredentials(AuthenticationContext context, RequestBase request, Out<Credentials> out) throws ServletException, IOException {
    if(request.isMethod(Method.POST) && request.hasParameter(usernameParameter)){
      //Validates username
      String username = request.getParameter(usernameParameter);
      if(context.validation()
            .required(usernameParameter, username)
            .errors().contains(usernameParameter)){
        return true;
      }
      context.setIdentity(username);
      //Validates password if necessary
      String password = request.getParameter(passwordParameter);
      if(passwordRequired && context.validation().required(passwordParameter, password)
          .errors().contains(passwordParameter)){
        return true;
      }
      
      log.debug("Resolved 'UsernamePasswordCredentials' : [username={}]",username);
      
      out.set(new SimpleUsernamePasswordCredentials(username, password));
      return true;
    }
    
    return false;
  }
}

代码示例来源:origin: org.leapframework/leap-webapi

@Override
public boolean handleFailure(ActionContext context, ActionExecution execution, Result result) {
  Response response = context.getResponse();
  ApiErrorHandler errorHandler = getErrorHandler(context);
  if(execution.isValidationError()) {
    handleValidationError(errorHandler, response, execution.getValidation().errors());
    return true;
  }
  if(execution.hasException()) {
    Throwable e = execution.getException();
    for(ApiExceptionHandler handler : exceptionHandlers) {
      if(handler.handleApiException(errorHandler, context, execution, response, e)) {
        return true;
      }
    }
    if(handleException(errorHandler, response, e)) {
      return true;
    }
    //other exceptions.
    errorHandler.internalServerError(response, e.getMessage());
    return true;
  }
  errorHandler.internalServerError(response, "Execution failed.");
  return true;
}

代码示例来源:origin: org.leapframework/spring-boot-starter-jmms

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
  Object value = wrapped.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
  Argument a = mapping.params.get(parameter.getParameterName());
  if(null != a && a.getValidators().length > 0) {
    Out<Object> out = new Out<>();
    Validation validation = validationManager.createValidation();
    for(ArgumentValidator v : a.getValidators()) {
      if(!v.validate(validation, a, value, out)) {
        String name = Conventions.getVariableNameForParameter(parameter);
        BindingResult bindingResult = binderFactory.createBinder(webRequest, value, name).getBindingResult();
        bindingResult.addError(new ObjectError(name, validation.errors().getMessage()));
        throw new MethodArgumentNotValidException(parameter, bindingResult);
      }
    }
    /*
    if(out.isPresent()) {
      value = out.getAndReset();
    }
    */
  }
  return value;
}

代码示例来源:origin: org.leapframework/leap-oauth2

String errorKey = INVALID_REQUEST_INVALID_USERNAME;
if(context.validation().hasErrors()){
  NamedError error = validation.errors().first();
  if(Strings.equals(error.getName(),UsernamePasswordCredentials.PASSWORD)){
    errorKey = INVALID_REQUEST_INVALID_PASSWORD;

代码示例来源:origin: org.leapframework/leap-oauth2-server

String errorKey = INVALID_REQUEST_INVALID_USERNAME;
if(context.validation().hasErrors()){
  NamedError error = validation.errors().first();
  if(Strings.equals(error.getName(),UsernamePasswordCredentials.PASSWORD)){
    errorKey = INVALID_REQUEST_INVALID_PASSWORD;

相关文章