package pl.dmcs.mati.validator;

import org.apache.commons.validator.routines.EmailValidator;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
import pl.dmcs.mati.domain.AppUser;

public class AppCarValidator implements Validator {

    @Override
    public boolean supports(Class clazz) {return AppUser.class.isAssignableFrom(clazz);}

    @Override
    public void validate(Object arg0, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors, "brandName", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "modelName", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "bodyType", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "productionYear", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "carColor", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "fuelType", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "engineSize", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "mileage", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "power", "error.field.required");
        ValidationUtils.rejectIfEmpty(errors, "Vin", "error.field.required");

        }
    }

