All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dwivedi.androidformvalidation.validator.validations.MatchPattern Maven / Gradle / Ivy

package com.dwivedi.androidformvalidation.validator.validations;

import android.content.Context;

/**
 * 
 * @author Created by Ashish Dwivedi (see
 *         https://github.com/dwivedi/AndroidFormValidation-TheRightWay).
 *         Modified and incorporated to ioc-commons-android-impl by Jesús Lunar
 *         Pérez
 */

public class MatchPattern extends BaseValidation {

	private String pattern;
	private int errorMessageId;

	private MatchPattern(Context context, String pattern, int errorMessageId) {
		super(context);
		this.errorMessageId = errorMessageId;
		this.pattern=pattern;
	}

	public static Validation build(Context context, String pattern, int errorMessageId) {
		return new MatchPattern(context, pattern, errorMessageId);
	}

	@Override
	public String getErrorMessage() {
		return mContext.getString(this.errorMessageId);
	}

	@Override
	public boolean isValid(String text) {
		return text.matches(this.pattern);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy