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

com.dwivedi.androidformvalidation.validator.validations.IsPositiveInteger 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 IsPositiveInteger extends BaseValidation {

	public static final String POSITIVE_INT_PATTERN = "\\d+";
	private int errorMessageId;

	private IsPositiveInteger(Context context, int errorMessageId) {
		super(context);
		this.errorMessageId = errorMessageId;
	}

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy