@Override
    public void validate(Object obj, Errors errors) {

        Book pi = (Book) obj;

        if (pi == null) {
            errors.rejectValue("pages", "error.not-specified", null, "Value required.");
            return;
        }

        if (pi.getPages() != null && pi.getPages() > maxPages) 
        {
            errors.rejectValue("pages", "error.too-high",new Object[]{new Integer(maxPages)}, "Value too high.");
        }

        if (pi.getPages() != null && pi.getPages() <= minPages) 
        {
            errors.rejectValue("pages", "error.too-low",new Object[]{new Integer(minPages)}, "Value too low.");
        }

        if (pi.getSubject() ==null || pi.getSubject().length()<=0) 
        {
            errors.rejectValue("subject", "error.required",new Object[]{"Subject"}, "Value Is Required.");
        }

        if (pi.getTitle() ==null || pi.getTitle().length()<=0) 
        {
            errors.rejectValue("title", "error.required",new Object[]{"Title"}, "Value Is Required.");
        }

    }