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

br.com.jhonsapp.util.verifier.CepVerifier Maven / Gradle / Ivy

Go to download

This project provides useful classes that facilitate the construction of new components.

There is a newer version: 1.0.8
Show newest version
package br.com.jhonsapp.util.verifier;

import java.util.regex.Pattern;

/**
 * This class verify Cep conditions.
 * 
 * @author Jhonathan Camacho
 *
 */
public class CepVerifier {

	/**
	 * Verify if the cep is valid.
	 * 
	 * @param cep
	 *            the cep that wil be verified.
	 * @return true if the cep is valid. Return false otherwise.
	 */
	public static boolean isValid(String cep) {
		Pattern pattern = Pattern.compile("^[0-9]{8}$");
		return StringVerifier.notBlanck(cep) && pattern.matcher(cep).matches();
	}

	/**
	 * Verify if the cep is invalid.
	 * 
	 * @param cep
	 *            the cep that wil be verified.
	 * @return true if the cep is invalid. Return false otherwise.
	 */
	public static boolean isInvalid(String cep) {
		Pattern pattern = Pattern.compile("^[0-9]{8}$");
		return StringVerifier.isBlanck(cep) || !pattern.matcher(cep).matches();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy