@Override public IValidationResult isIdentityValid(UserVO object) { if (object == null) { return new ValidationResult(true, "User object cannot be null"); } if (object.getId() == null || object.getId() < 1) { return new ValidationResult( true, "User id cannot be null or lesser that 1 :" + object.getId()); } return new ValidationResult(false, ""); }
private IResolution parseAddRequest(IExecutionContext context) throws DataRetrievalException, DataWriteException { UserVO user = new UserVO(); try { beanUtilsHelper.populateBean(user, context.getParameterMap()); user.setGroup(accessManager.retrieveGroup(Long.parseLong(context.getParameter("group_id")))); accessManager.writeUser(user); return new RedirectResolution("index.html?action=" + AvailableActionType.VIEW); } catch (ValidationException ex) { context.addValidationError(ex.getValidationResult().getValidationResultMessage()); return parseEditRequest(user, context); } }
@Override public IValidationResult isValid(UserVO object) { if (object == null) { return new ValidationResult(true, "User object cannot be null"); } if (object.getName() == null || object.getName().length() < 2) { return new ValidationResult(true, "User name cannot be null or shorter than 5 chars"); } if (object.getLogin() == null || object.getLogin().length() < 5) { return new ValidationResult(true, "User login cannot be null or shorter than 5 chars"); } if (object.getPassword() == null || object.getPassword().length() < 5) { return new ValidationResult(true, "User password cannot be null or shorter that 5 chars"); } return new ValidationResult(false, ""); }