@@ -0,0 +1,1820 @@
+%0Apackage com.cross.dao.pojo.customvalidators;%0A%0A %0A%0Aimport com.cross.dao.pojo.UploadImage;%0Aimport java.awt.Image;%0Aimport java.io.IOException;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0Aimport javax.imageio.ImageIO;%0Aimport org.springframework.stereotype.Component;%0Aimport org.springframework.validation.Errors;  %0Aimport org.springframework.validation.Validator; %0A%0A%0A     /**%0A      @author to Ibrahim Abdsaid Hanna @2016%0A                 ibrahim.seniore@gmail.com%0A    */ %0A%0A@Component%0Apublic class ImageValidator implements Validator %7B %0A %0A  %0A    %0A    %0A     @Override%0A    public boolean supports(Class%3C?%3E type) %7B       %0A       return UploadImage.class.isAssignableFrom(type);%0A    %7D %0A%0A     @Override%0A    public void validate(Object obj, Errors errors) %7B %0A%0A         try %7B%0A             UploadImage uploadImage = (UploadImage) obj;%0A             %0A             if (uploadImage.getFile().getSize() == 0) %7B%0A                 errors.rejectValue(%22file%22, %22global.image.notselected%22);%0A             %7D%0A             else if (uploadImage.getFile().getBytes().length %3E2048*1000 ) %7B%0A                 errors.rejectValue(%22file%22, %22global.image.illegalsize%22);%0A             %7D%0A     %0A             else%7B%0A                 Image image=null;%0A                 try %7B%0A                     image = ImageIO.read(uploadImage.getFile().getInputStream());%0A                 %7D catch (IOException ex) %7B%0A                     Logger.getLogger(ImageValidator.class.getName()).log(Level.SEVERE, null, ex);%0A                 %7D%0A                 %0A                 if(image==null)%7B%0A                     errors.rejectValue(%22file%22, %22global.image.notsupported%22);%0A                 %7D%0A             %7D%0A         %7D catch (Exception ex) %7B%0A             Logger.getLogger(ImageValidator.class.getName()).log(Level.SEVERE, null, ex);%0A         %7D%0A              %0A    %7D %0A%7D %0A

Create ImageValidator.java