-
Notifications
You must be signed in to change notification settings - Fork 4
/
ValidationUtils.java
44 lines (39 loc) · 1.06 KB
/
ValidationUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.bytesizebit.androidutils;
import android.util.Patterns;
/******
* Android Utils
* Created by Shahar Barsheshet on 08/08/2016.
* bytesizebit@gmail.com
* www.bytesizebit.com
******/
public class ValidationUtils {
private ValidationUtils() {
}
/**
* Check if an email is valid
*
* @param email the email to check
* @return {@code true} if the email is valid
*/
public static boolean isValidEmail(String email) {
return Patterns.EMAIL_ADDRESS.matcher(email).matches();
}
/**
* Check if an IP Address is valid
*
* @param IPAddress the IP Address to check
* @return {@code true} if the email is valid
*/
public static boolean isValidIPAddress(String IPAddress) {
return Patterns.IP_ADDRESS.matcher(IPAddress).matches();
}
/**
* Check if a url is valid
*
* @param url the url to check
* @return {@code true} if the url is valid
*/
public static boolean isValidUrl(String url) {
return Patterns.WEB_URL.matcher(url).matches();
}
}