package com.mason.server.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;

import com.mason.server.model.Project;

public class ProjectValidator extends BasicValidator {

	@Override
	public boolean supports(Class<?> c) {
		return Project.class.equals(c);
	}

	@Override
	public void validate(Object obj, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description",
				"description.null");

		Project p = (Project) obj;
		if (!this.validateDescription(p.getDescription())) {
			errors.reject("description", "description.not.alphanumeric");
		}
	}

}
