package com.mason.server.validator;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.validation.Validator;

public abstract class BasicValidator implements Validator {

	private Pattern pattern;
	private Matcher matcher;

	private static final String DESCRIPTION_PATTERN = "^[A-Za-z0-9 _]*[A-Za-z0-9][A-Za-z0-9 _]*$";

	public BasicValidator() {
		pattern = Pattern.compile(DESCRIPTION_PATTERN);
	}

	public boolean validateDescription(final String string) {
		matcher = pattern.matcher(string);

		return matcher.matches();
	}

}
