/**
 * BoardForm 객체에 대한 유효성 검증
 */
package org.springframework.samples.kyuriboard.domain.logic;

import org.springframework.samples.kyuriboard.domain.Board;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.validation.ValidationUtils;

/**
 * @author DAMI(archy712@naver.com)
 *
 */
public class BoardValidator implements Validator {

	/* (non-Javadoc)
	 * @see org.springframework.validation.Validator#supports(java.lang.Class)
	 */
	public boolean supports(Class clazz) {
		// TODO Auto-generated method stub
		return Board.class.isAssignableFrom(clazz);
	}

	/* (non-Javadoc)
	 * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
	 */
	public void validate(Object obj, Errors errors) {
		// TODO Auto-generated method stub
		ValidationUtils.rejectIfEmpty(errors, "title", "TITLE_REQUIRED", "글 제목이 필요합니다");
		ValidationUtils.rejectIfEmpty(errors, "content", "CONTENT_REQUIRED", "글 내용이 필요합니다");
	}

}
