Package com.yourpackagename.framework.validation

Examples of com.yourpackagename.framework.validation.Validity


    }


    @Override public Validity validate(User user) {
        EntityValidator<User> entityValidator = new EntityValidator<User>();
        Validity validity = entityValidator.validate(user, User.class);

        // Check for username and email uniqueness
        if (isUsernameExists(user.getUserName())) {
            validity.addError(msg.userExists);
        }

        if (isEmailExists(user.getEmail())) {
            validity.addError(msg.emailExists);
        }

        return validity;
    }
View Full Code Here


    @RequestMapping(value = Route.registerUser, method = RequestMethod.POST, consumes = Key.formEncoded)
    public String registerUser(Locale locale, Model model,
                                   @ModelAttribute(Key.regUserForm) UserRO userRO) {
        try {
            User u = userRO.user(props);
            Validity validity = userService.validate(u);
            if (validity.isValid()) {
                userService.registerUser(u, request);
                mailSenderActor.sendUserEmailIdConfirmationMail(u);
                request.getSession(true).setAttribute(Key.userInSession, u);
                model.addAttribute(Key.isRegister, true);
                return Key.redirect + Route.dashboard;
View Full Code Here


    public Response validateAndSaveEntity(Entity entity, BaseService service) {
        Response response = serverResponse();
        try {
            Validity vsEntity = service.validate(entity);
            if (vsEntity.isValid()) {
                service.insert(entity);
                response.setResult(entity);
            } else {
                response.setError(key.vdnCode, vsEntity.errors());
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            response.setError(key.iseCode, e.getMessage());
        }
View Full Code Here

                                               @RequestHeader("pass") String password) {
        Response response = serverResponse();
        try {
            User user = userRO.user(props);
            user.setPassWord(password);
            Validity vsUser = userService.validate(user);
            if (vsUser.isValid()) {
                userService.registerUser(user, request);
                response.setResult(user);
            } else {
                response.setError(key.vdnCode, vsUser.errorMsgs());
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            response.setError(key.iseCode, e.getMessage());
        }
View Full Code Here

TOP

Related Classes of com.yourpackagename.framework.validation.Validity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.