class RelationshipValidator implements Validator {

	@Override
	public void validate(Object target, Errors errors) {
		Relationship relationship = (Relationship) target;
		
		if (relationship != null) {
			Date startDate = relationship.getStartDate();
			Date endDate = relationship.getEndDate();
			if (startDate != null && endDate != null && startDate.after(endDate)) {
				errors.reject("Relationship.InvalidEndDate.error");
			}
			ValidateUtil.validateFieldLengths(errors, target.getClass(), "voidReason");
			if (startDate != null) {
				Date currentDate = new Date();
				if (startDate.after(currentDate)) {
					errors.reject("error.date.future");
				}
			}
		}
		
	}

}