Package org.nocturne.validation

Examples of org.nocturne.validation.ValidationException


    @Override
    public void run(String value) throws ValidationException {
        try {
            Pattern.compile(value);
        } catch (PatternSyntaxException e) {
            throw new ValidationException($("Illegal regex: {0}", e.getMessage()));
        }
    }
View Full Code Here


                return;
            }

            throw new NumberFormatException();
        } catch (NumberFormatException e) {
            throw new ValidationException($("Enter codes in the following format: int[ - toInt] [, int[ - toInt]] ..."));
        }
    }
View Full Code Here

    private static final Pattern TIME_PATTERN = Pattern.compile("^\\s*([0-1]?[0-9]|2[0-4])\\s*:\\s*([0-5][0-9])\\s*$");

    @Override
    public void run(String value) throws ValidationException {
        if (!StringUtils.isBlank(value) && !TIME_PATTERN.matcher(value).matches()) {
            throw new ValidationException($("Enter time in format HH:MM or leave field blank."));
        }
    }
View Full Code Here

    @Override
    public void run(String value) throws ValidationException {
        try {
            URL url = new URL(value);
            if (!"http".equalsIgnoreCase(url.getProtocol())) {
                throw new ValidationException($("Only http protocol is supported"));
            }
        } catch (MalformedURLException e) {
            throw new ValidationException($("Enter valid URL"));
        }
    }
View Full Code Here

    public void run(String value) throws ValidationException {
        if (password == null && value == null || password != null && password.equals(value)) {
            return;
        }

        throw new ValidationException($("Password confirmation was failed."));
    }
View Full Code Here

        long numeric;

        try {
            numeric = Long.parseLong(value);
        } catch (Exception e) {
            throw new ValidationException($("Field should contain long integer value"));
        }

        if (numeric < minimalValue) {
            throw new ValidationException($("Field should be at least {0}", minimalValue));
        }

        if (numeric > maximalValue) {
            throw new ValidationException($("Field should be no more than {0}", maximalValue));
        }
    }
View Full Code Here

        addValidator("password", new RequiredValidator());
        addValidator("password", new Validator() {
            @Override
            public void run(String value) throws ValidationException {
                if (userDao.findByEmailAndPassword(email, password) == null) {
                    throw new ValidationException($("Invalid email or password"));
                }
            }
        });

        return runValidation();
View Full Code Here

TOP

Related Classes of org.nocturne.validation.ValidationException

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.