forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidators.dart
More file actions
25 lines (22 loc) · 949 Bytes
/
Copy pathvalidators.dart
File metadata and controls
25 lines (22 loc) · 949 Bytes
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
bool isValidUrl(String url) {
const urlPattern = r'^(https?:\/\/)?([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)?'
r'((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}'
r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|'
r'([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,63}(:[0-9]+)?(\/.*)?$';
return RegExp(urlPattern).hasMatch(url);
}
bool isValidPayPalMeUrl(String url) {
const payPalMePattern = r'^paypal\.me\/[a-zA-Z0-9-]+$';
return RegExp(payPalMePattern).hasMatch(url);
}
bool isValidWebSocketUrl(String url) {
const webSocketPattern = r'^(wss?:\/\/)?([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)?'
r'((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}'
r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|'
r'([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,63}(:[0-9]+)?(\/.*)?$';
return RegExp(webSocketPattern).hasMatch(url);
}
bool isValidEmail(String email) {
const emailPattern = r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$';
return RegExp(emailPattern).hasMatch(email);
}