/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.csu.sdmx.web.validators;

import cz.csu.sdmx.web.forms.DetectDsdForm;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
 *
 * @author themi
 */
@Component
public class DetectDsdFormValidator implements Validator{

    @Override
    public boolean supports(Class<?> type) {
        return DetectDsdForm.class.isAssignableFrom(type);
    }

    @Override
    public void validate(Object o, Errors errors) {
        DetectDsdForm form = (DetectDsdForm) o;
        
        if(form.getDsdFile().isEmpty()){
            errors.rejectValue("DSDFile","dd", "DSD file required.");
        }
    }
}
