Showing
6 changed files
with
96 additions
and
264 deletions
@@ -15,13 +15,6 @@ packages: | @@ -15,13 +15,6 @@ packages: | ||
15 | url: "https://pub.dartlang.org" | 15 | url: "https://pub.dartlang.org" |
16 | source: hosted | 16 | source: hosted |
17 | version: "0.39.10" | 17 | version: "0.39.10" |
18 | - archive: | ||
19 | - dependency: transitive | ||
20 | - description: | ||
21 | - name: archive | ||
22 | - url: "https://pub.dartlang.org" | ||
23 | - source: hosted | ||
24 | - version: "2.0.13" | ||
25 | args: | 18 | args: |
26 | dependency: transitive | 19 | dependency: transitive |
27 | description: | 20 | description: |
@@ -277,13 +270,6 @@ packages: | @@ -277,13 +270,6 @@ packages: | ||
277 | url: "https://pub.dartlang.org" | 270 | url: "https://pub.dartlang.org" |
278 | source: hosted | 271 | source: hosted |
279 | version: "3.1.4" | 272 | version: "3.1.4" |
280 | - image: | ||
281 | - dependency: transitive | ||
282 | - description: | ||
283 | - name: image | ||
284 | - url: "https://pub.dartlang.org" | ||
285 | - source: hosted | ||
286 | - version: "2.1.12" | ||
287 | io: | 273 | io: |
288 | dependency: transitive | 274 | dependency: transitive |
289 | description: | 275 | description: |
@@ -389,13 +375,6 @@ packages: | @@ -389,13 +375,6 @@ packages: | ||
389 | url: "https://pub.dartlang.org" | 375 | url: "https://pub.dartlang.org" |
390 | source: hosted | 376 | source: hosted |
391 | version: "1.9.0" | 377 | version: "1.9.0" |
392 | - petitparser: | ||
393 | - dependency: transitive | ||
394 | - description: | ||
395 | - name: petitparser | ||
396 | - url: "https://pub.dartlang.org" | ||
397 | - source: hosted | ||
398 | - version: "2.4.0" | ||
399 | pool: | 378 | pool: |
400 | dependency: transitive | 379 | dependency: transitive |
401 | description: | 380 | description: |
@@ -562,13 +541,6 @@ packages: | @@ -562,13 +541,6 @@ packages: | ||
562 | url: "https://pub.dartlang.org" | 541 | url: "https://pub.dartlang.org" |
563 | source: hosted | 542 | source: hosted |
564 | version: "1.1.0" | 543 | version: "1.1.0" |
565 | - xml: | ||
566 | - dependency: transitive | ||
567 | - description: | ||
568 | - name: xml | ||
569 | - url: "https://pub.dartlang.org" | ||
570 | - source: hosted | ||
571 | - version: "3.6.1" | ||
572 | yaml: | 544 | yaml: |
573 | dependency: transitive | 545 | dependency: transitive |
574 | description: | 546 | description: |
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | - | ||
3 | import 'package:flutter/widgets.dart'; | 2 | import 'package:flutter/widgets.dart'; |
4 | import 'package:get/src/state_manager/rx/rx_interface.dart'; | 3 | import 'package:get/src/state_manager/rx/rx_interface.dart'; |
5 | - | ||
6 | import 'rx_impl.dart'; | 4 | import 'rx_impl.dart'; |
7 | 5 | ||
8 | Widget obx(Widget Function() builder) { | 6 | Widget obx(Widget Function() builder) { |
@@ -96,7 +94,7 @@ class _ObxState extends State<Obx> { | @@ -96,7 +94,7 @@ class _ObxState extends State<Obx> { | ||
96 | /// false.obs, | 94 | /// false.obs, |
97 | /// ), | 95 | /// ), |
98 | 96 | ||
99 | -// TODO: change T to a proper Rx interfase, that includes the accessor for ::value | 97 | +// TODO: change T to a proper Rx interface, that includes the accessor for ::value |
100 | class ObxValue<T extends RxInterface> extends StatefulWidget { | 98 | class ObxValue<T extends RxInterface> extends StatefulWidget { |
101 | final Widget Function(T) builder; | 99 | final Widget Function(T) builder; |
102 | final T data; | 100 | final T data; |
@@ -10,7 +10,7 @@ extension GetStringUtils on String { | @@ -10,7 +10,7 @@ extension GetStringUtils on String { | ||
10 | bool get isAudioFileName => GetUtils.isAudio(this); | 10 | bool get isAudioFileName => GetUtils.isAudio(this); |
11 | bool get isVideoFileName => GetUtils.isVideo(this); | 11 | bool get isVideoFileName => GetUtils.isVideo(this); |
12 | bool get isTxtFileName => GetUtils.isTxt(this); | 12 | bool get isTxtFileName => GetUtils.isTxt(this); |
13 | - bool get isDocumentFileName => GetUtils.isDocument(this); | 13 | + bool get isDocumentFileName => GetUtils.isWord(this); |
14 | bool get isExcelFileName => GetUtils.isExcel(this); | 14 | bool get isExcelFileName => GetUtils.isExcel(this); |
15 | bool get isPPTFileName => GetUtils.isPPT(this); | 15 | bool get isPPTFileName => GetUtils.isPPT(this); |
16 | bool get isAPKFileName => GetUtils.isAPK(this); | 16 | bool get isAPKFileName => GetUtils.isAPK(this); |
@@ -23,7 +23,6 @@ extension GetStringUtils on String { | @@ -23,7 +23,6 @@ extension GetStringUtils on String { | ||
23 | bool get isMD5 => GetUtils.isMD5(this); | 23 | bool get isMD5 => GetUtils.isMD5(this); |
24 | bool get isSHA1 => GetUtils.isSHA1(this); | 24 | bool get isSHA1 => GetUtils.isSHA1(this); |
25 | bool get isSHA256 => GetUtils.isSHA256(this); | 25 | bool get isSHA256 => GetUtils.isSHA256(this); |
26 | - bool get isISBN => GetUtils.isISBN(this); | ||
27 | bool get isBinary => GetUtils.isBinary(this); | 26 | bool get isBinary => GetUtils.isBinary(this); |
28 | bool get isIPv4 => GetUtils.isIPv4(this); | 27 | bool get isIPv4 => GetUtils.isIPv4(this); |
29 | bool get isIPv6 => GetUtils.isIPv6(this); | 28 | bool get isIPv6 => GetUtils.isIPv6(this); |
1 | -import 'package:get/src/utils/regex/regex.dart'; | ||
2 | - | ||
3 | class GetUtils { | 1 | class GetUtils { |
4 | /// Checks if data is null. | 2 | /// Checks if data is null. |
5 | static bool isNull(dynamic s) => s == null; | 3 | static bool isNull(dynamic s) => s == null; |
@@ -28,12 +26,10 @@ class GetUtils { | @@ -28,12 +26,10 @@ class GetUtils { | ||
28 | 26 | ||
29 | /// Checks if string consist only numeric. | 27 | /// Checks if string consist only numeric. |
30 | /// Numeric only doesn't accepting "." which double data type have | 28 | /// Numeric only doesn't accepting "." which double data type have |
31 | - static bool isNumericOnly(String s) => | ||
32 | - RegexValidation.hasMatch(s, regex.numericOnly); | 29 | + static bool isNumericOnly(String s) => hasMatch(s, r'^\d+$'); |
33 | 30 | ||
34 | /// Checks if string consist only Alphabet. (No Whitespace) | 31 | /// Checks if string consist only Alphabet. (No Whitespace) |
35 | - static bool isAlphabetOnly(String s) => | ||
36 | - RegexValidation.hasMatch(s, regex.alphabetOnly); | 32 | + static bool isAlphabetOnly(String s) => hasMatch(s, r'^[a-zA-Z]+$'); |
37 | 33 | ||
38 | /// Checks if string is boolean. | 34 | /// Checks if string is boolean. |
39 | static bool isBool(String s) { | 35 | static bool isBool(String s) { |
@@ -41,81 +37,133 @@ class GetUtils { | @@ -41,81 +37,133 @@ class GetUtils { | ||
41 | return (s == 'true' || s == 'false'); | 37 | return (s == 'true' || s == 'false'); |
42 | } | 38 | } |
43 | 39 | ||
44 | - /// Checks if string is an vector file. | ||
45 | - static bool isVector(String s) => RegexValidation.hasMatch(s, regex.vector); | 40 | + /// Checks if string is an video file. |
41 | + static bool isVideo(String filePath) { | ||
42 | + String ext = filePath.toLowerCase(); | ||
43 | + return (((((ext.endsWith(".mp4") || ext.endsWith(".avi")) || | ||
44 | + ext.endsWith(".wmv")) || | ||
45 | + ext.endsWith(".rmvb")) || | ||
46 | + ext.endsWith(".mpg")) || | ||
47 | + ext.endsWith(".mpeg")) || | ||
48 | + ext.endsWith(".3gp"); | ||
49 | + } | ||
46 | 50 | ||
47 | /// Checks if string is an image file. | 51 | /// Checks if string is an image file. |
48 | - static bool isImage(String s) => RegexValidation.hasMatch(s, regex.image); | 52 | + static bool isImage(String filePath) { |
53 | + String ext = filePath.toLowerCase(); | ||
54 | + return (((ext.endsWith(".jpg") || ext.endsWith(".jpeg")) || | ||
55 | + ext.endsWith(".png")) || | ||
56 | + ext.endsWith(".gif")) || | ||
57 | + ext.endsWith(".bmp"); | ||
58 | + } | ||
49 | 59 | ||
50 | /// Checks if string is an audio file. | 60 | /// Checks if string is an audio file. |
51 | - static bool isAudio(String s) => RegexValidation.hasMatch(s, regex.audio); | 61 | + static bool isAudio(String filePath) { |
62 | + String ext = filePath.toLowerCase(); | ||
63 | + return (((ext.endsWith(".mp3") || ext.endsWith(".wav")) || | ||
64 | + ext.endsWith(".wma")) || | ||
65 | + ext.endsWith(".amr")) || | ||
66 | + ext.endsWith(".ogg"); | ||
67 | + } | ||
52 | 68 | ||
53 | - /// Checks if string is an video file. | ||
54 | - static bool isVideo(String s) => RegexValidation.hasMatch(s, regex.video); | 69 | + /// Checks if string is an powerpoint file. |
70 | + static bool isPPT(String filePath) { | ||
71 | + String ext = filePath.toLowerCase(); | ||
72 | + return ext.endsWith(".ppt") || ext.endsWith(".pptx"); | ||
73 | + } | ||
55 | 74 | ||
56 | - /// Checks if string is an txt file. | ||
57 | - static bool isTxt(String s) => RegexValidation.hasMatch(s, regex.txt); | 75 | + /// Checks if string is an word file. |
76 | + static bool isWord(String filePath) { | ||
77 | + String ext = filePath.toLowerCase(); | ||
78 | + return ext.endsWith(".doc") || ext.endsWith(".docx"); | ||
79 | + } | ||
58 | 80 | ||
59 | - /// Checks if string is an Doc file. | ||
60 | - static bool isDocument(String s) => RegexValidation.hasMatch(s, regex.doc); | 81 | + /// Checks if string is an excel file. |
82 | + static bool isExcel(String filePath) { | ||
83 | + String ext = filePath.toLowerCase(); | ||
84 | + return ext.endsWith(".xls") || ext.endsWith(".xlsx"); | ||
85 | + } | ||
61 | 86 | ||
62 | - /// Checks if string is an Excel file. | ||
63 | - static bool isExcel(String s) => RegexValidation.hasMatch(s, regex.excel); | 87 | + /// Checks if string is an apk file. |
88 | + static bool isAPK(String filePath) { | ||
89 | + return filePath.toLowerCase().endsWith(".apk"); | ||
90 | + } | ||
64 | 91 | ||
65 | - /// Checks if string is an PPT file. | ||
66 | - static bool isPPT(String s) => RegexValidation.hasMatch(s, regex.ppt); | 92 | + /// Checks if string is an pdf file. |
93 | + static bool isPDF(String filePath) { | ||
94 | + return filePath.toLowerCase().endsWith(".pdf"); | ||
95 | + } | ||
67 | 96 | ||
68 | - /// Checks if string is an APK file. | ||
69 | - static bool isAPK(String s) => RegexValidation.hasMatch(s, regex.apk); | 97 | + /// Checks if string is an txt file. |
98 | + static bool isTxt(String filePath) { | ||
99 | + return filePath.toLowerCase().endsWith(".txt"); | ||
100 | + } | ||
70 | 101 | ||
71 | - /// Checks if string is an video file. | ||
72 | - static bool isPDF(String s) => RegexValidation.hasMatch(s, regex.pdf); | 102 | + /// Checks if string is an chm file. |
103 | + static bool isChm(String filePath) { | ||
104 | + return filePath.toLowerCase().endsWith(".chm"); | ||
105 | + } | ||
73 | 106 | ||
74 | - /// Checks if string is an HTML file. | ||
75 | - static bool isHTML(String s) => RegexValidation.hasMatch(s, regex.html); | 107 | + /// Checks if string is a vector file. |
108 | + static bool isVector(String filePath) { | ||
109 | + return filePath.toLowerCase().endsWith(".svg"); | ||
110 | + } | ||
111 | + | ||
112 | + /// Checks if string is an html file. | ||
113 | + static bool isHTML(String filePath) { | ||
114 | + return filePath.toLowerCase().endsWith(".html"); | ||
115 | + } | ||
116 | + | ||
117 | + /// Checks if string is a valid username. | ||
118 | + static bool isUsername(String s) => | ||
119 | + hasMatch(s, r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$'); | ||
76 | 120 | ||
77 | /// Checks if string is URL. | 121 | /// Checks if string is URL. |
78 | - static bool isURL(String s) => RegexValidation.hasMatch(s, regex.url); | 122 | + static bool isURL(String s) => hasMatch(s, |
123 | + r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$"); | ||
79 | 124 | ||
80 | /// Checks if string is email. | 125 | /// Checks if string is email. |
81 | - static bool isEmail(String s) => RegexValidation.hasMatch(s, regex.email); | 126 | + static bool isEmail(String s) => hasMatch(s, |
127 | + r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'); | ||
82 | 128 | ||
83 | /// Checks if string is phone number. | 129 | /// Checks if string is phone number. |
84 | - static bool isPhoneNumber(String s) => | ||
85 | - RegexValidation.hasMatch(s, regex.phone); | 130 | + static bool isPhoneNumber(String s) => hasMatch(s, |
131 | + r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$'); | ||
86 | 132 | ||
87 | /// Checks if string is DateTime (UTC or Iso8601). | 133 | /// Checks if string is DateTime (UTC or Iso8601). |
88 | static bool isDateTime(String s) => | 134 | static bool isDateTime(String s) => |
89 | - RegexValidation.hasMatch(s, regex.basicDateTime); | 135 | + hasMatch(s, r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$'); |
90 | 136 | ||
91 | /// Checks if string is MD5 hash. | 137 | /// Checks if string is MD5 hash. |
92 | - static bool isMD5(String s) => RegexValidation.hasMatch(s, regex.md5); | 138 | + static bool isMD5(String s) => hasMatch(s, r'^[a-f0-9]{32}$'); |
93 | 139 | ||
94 | /// Checks if string is SHA1 hash. | 140 | /// Checks if string is SHA1 hash. |
95 | - static bool isSHA1(String s) => RegexValidation.hasMatch(s, regex.sha1); | 141 | + static bool isSHA1(String s) => |
142 | + hasMatch(s, r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})'); | ||
96 | 143 | ||
97 | /// Checks if string is SHA256 hash. | 144 | /// Checks if string is SHA256 hash. |
98 | - static bool isSHA256(String s) => RegexValidation.hasMatch(s, regex.sha256); | ||
99 | - | ||
100 | - /// Checks if string is ISBN 10 or 13. | ||
101 | - static bool isISBN(String s) => RegexValidation.hasMatch(s, regex.isbn); | 145 | + static bool isSHA256(String s) => |
146 | + hasMatch(s, r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}'); | ||
102 | 147 | ||
103 | /// Checks if string is SSN (Social Security Number). | 148 | /// Checks if string is SSN (Social Security Number). |
104 | - static bool isSSN(String s) => RegexValidation.hasMatch(s, regex.ssn); | 149 | + static bool isSSN(String s) => hasMatch(s, |
150 | + r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$'); | ||
105 | 151 | ||
106 | /// Checks if string is binary. | 152 | /// Checks if string is binary. |
107 | - static bool isBinary(String s) => RegexValidation.hasMatch(s, regex.binary); | 153 | + static bool isBinary(String s) => hasMatch(s, r'^[0-1]*$'); |
108 | 154 | ||
109 | /// Checks if string is IPv4. | 155 | /// Checks if string is IPv4. |
110 | - static bool isIPv4(String s) => RegexValidation.hasMatch(s, regex.ipv4); | 156 | + static bool isIPv4(String s) => |
157 | + hasMatch(s, r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$'); | ||
111 | 158 | ||
112 | /// Checks if string is IPv6. | 159 | /// Checks if string is IPv6. |
113 | - static bool isIPv6(String s) => RegexValidation.hasMatch(s, regex.ipv6); | 160 | + static bool isIPv6(String s) => hasMatch(s, |
161 | + r'^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$'); | ||
114 | 162 | ||
115 | /// Checks if string is hexadecimal. | 163 | /// Checks if string is hexadecimal. |
116 | /// Example: HexColor => #12F | 164 | /// Example: HexColor => #12F |
117 | static bool isHexadecimal(String s) => | 165 | static bool isHexadecimal(String s) => |
118 | - RegexValidation.hasMatch(s, regex.hexadecimal); | 166 | + hasMatch(s, r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'); |
119 | 167 | ||
120 | /// Checks if string is Palindrom. | 168 | /// Checks if string is Palindrom. |
121 | static bool isPalindrom(String s) { | 169 | static bool isPalindrom(String s) { |
@@ -151,11 +199,11 @@ class GetUtils { | @@ -151,11 +199,11 @@ class GetUtils { | ||
151 | 199 | ||
152 | /// Checks if string is Passport No. | 200 | /// Checks if string is Passport No. |
153 | static bool isPassport(String s) => | 201 | static bool isPassport(String s) => |
154 | - RegexValidation.hasMatch(s, regex.passport); | 202 | + hasMatch(s, r'^(?!^0+$)[a-zA-Z0-9]{6,9}$'); |
155 | 203 | ||
156 | /// Checks if string is Currency. | 204 | /// Checks if string is Currency. |
157 | - static bool isCurrency(String s) => | ||
158 | - RegexValidation.hasMatch(s, regex.currency); | 205 | + static bool isCurrency(String s) => hasMatch(s, |
206 | + r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$'); | ||
159 | 207 | ||
160 | /// Checks if length of data is LOWER than maxLength. | 208 | /// Checks if length of data is LOWER than maxLength. |
161 | static bool isLengthLowerThan(dynamic s, int maxLength) { | 209 | static bool isLengthLowerThan(dynamic s, int maxLength) { |
@@ -425,11 +473,6 @@ class GetUtils { | @@ -425,11 +473,6 @@ class GetUtils { | ||
425 | return numericOnlyStr; | 473 | return numericOnlyStr; |
426 | } | 474 | } |
427 | 475 | ||
428 | - static Regex regex = Regex(); | ||
429 | -} | ||
430 | - | ||
431 | -class RegexValidation { | ||
432 | - /// Returns whether the pattern has a match in the string [input]. | ||
433 | static bool hasMatch(String s, Pattern p) => | 476 | static bool hasMatch(String s, Pattern p) => |
434 | (s == null) ? false : RegExp(p).hasMatch(s); | 477 | (s == null) ? false : RegExp(p).hasMatch(s); |
435 | } | 478 | } |
@@ -10,7 +10,7 @@ extension GetStringUtils on String { | @@ -10,7 +10,7 @@ extension GetStringUtils on String { | ||
10 | bool get isAudioFileName => GetUtils.isAudio(this); | 10 | bool get isAudioFileName => GetUtils.isAudio(this); |
11 | bool get isVideoFileName => GetUtils.isVideo(this); | 11 | bool get isVideoFileName => GetUtils.isVideo(this); |
12 | bool get isTxtFileName => GetUtils.isTxt(this); | 12 | bool get isTxtFileName => GetUtils.isTxt(this); |
13 | - bool get isDocumentFileName => GetUtils.isDocument(this); | 13 | + bool get isDocumentFileName => GetUtils.isWord(this); |
14 | bool get isExcelFileName => GetUtils.isExcel(this); | 14 | bool get isExcelFileName => GetUtils.isExcel(this); |
15 | bool get isPPTFileName => GetUtils.isPPT(this); | 15 | bool get isPPTFileName => GetUtils.isPPT(this); |
16 | bool get isAPKFileName => GetUtils.isAPK(this); | 16 | bool get isAPKFileName => GetUtils.isAPK(this); |
@@ -23,7 +23,6 @@ extension GetStringUtils on String { | @@ -23,7 +23,6 @@ extension GetStringUtils on String { | ||
23 | bool get isMD5 => GetUtils.isMD5(this); | 23 | bool get isMD5 => GetUtils.isMD5(this); |
24 | bool get isSHA1 => GetUtils.isSHA1(this); | 24 | bool get isSHA1 => GetUtils.isSHA1(this); |
25 | bool get isSHA256 => GetUtils.isSHA256(this); | 25 | bool get isSHA256 => GetUtils.isSHA256(this); |
26 | - bool get isISBN => GetUtils.isISBN(this); | ||
27 | bool get isBinary => GetUtils.isBinary(this); | 26 | bool get isBinary => GetUtils.isBinary(this); |
28 | bool get isIPv4 => GetUtils.isIPv4(this); | 27 | bool get isIPv4 => GetUtils.isIPv4(this); |
29 | bool get isIPv6 => GetUtils.isIPv6(this); | 28 | bool get isIPv6 => GetUtils.isIPv6(this); |
@@ -53,22 +52,6 @@ extension GetNumUtils on num { | @@ -53,22 +52,6 @@ extension GetNumUtils on num { | ||
53 | } | 52 | } |
54 | 53 | ||
55 | extension GetDynamicUtils on dynamic { | 54 | extension GetDynamicUtils on dynamic { |
56 | - /// It's This is overloading the IDE's options. Only the most useful and popular options will stay here. | ||
57 | - | ||
58 | bool get isNull => GetUtils.isNull(this); | 55 | bool get isNull => GetUtils.isNull(this); |
59 | bool get isNullOrBlank => GetUtils.isNullOrBlank(this); | 56 | bool get isNullOrBlank => GetUtils.isNullOrBlank(this); |
60 | - | ||
61 | - // bool get isOneAKind => GetUtils.isOneAKind(this); | ||
62 | - // bool isLengthLowerThan(int maxLength) => | ||
63 | - // GetUtils.isLengthLowerThan(this, maxLength); | ||
64 | - // bool isLengthGreaterThan(int maxLength) => | ||
65 | - // GetUtils.isLengthGreaterThan(this, maxLength); | ||
66 | - // bool isLengthGreaterOrEqual(int maxLength) => | ||
67 | - // GetUtils.isLengthGreaterOrEqual(this, maxLength); | ||
68 | - // bool isLengthLowerOrEqual(int maxLength) => | ||
69 | - // GetUtils.isLengthLowerOrEqual(this, maxLength); | ||
70 | - // bool isLengthEqualTo(int maxLength) => | ||
71 | - // GetUtils.isLengthEqualTo(this, maxLength); | ||
72 | - // bool isLengthBetween(int minLength, int maxLength) => | ||
73 | - // GetUtils.isLengthBetween(this, minLength, maxLength); | ||
74 | } | 57 | } |
1 | -class Regex { | ||
2 | - /// Username regex | ||
3 | - Pattern username = r'^[a-zA-Z0-9][a-zA-Z0-9_.]+[a-zA-Z0-9]$'; | ||
4 | - | ||
5 | - /// Email regex | ||
6 | - Pattern email = | ||
7 | - r'^[a-z0-9]+([-+._][a-z0-9]+){0,2}@.*?(\.(a(?:[cdefgilmnoqrstuwxz]|ero|(?:rp|si)a)|b(?:[abdefghijmnorstvwyz]iz)|c(?:[acdfghiklmnoruvxyz]|at|o(?:m|op))|d[ejkmoz]|e(?:[ceghrstu]|du)|f[ijkmor]|g(?:[abdefghilmnpqrstuwy]|ov)|h[kmnrtu]|i(?:[delmnoqrst]|n(?:fo|t))|j(?:[emop]|obs)|k[eghimnprwyz]|l[abcikrstuvy]|m(?:[acdeghklmnopqrstuvwxyz]|il|obi|useum)|n(?:[acefgilopruz]|ame|et)|o(?:m|rg)|p(?:[aefghklmnrstwy]|ro)|qa|r[eosuw]|s[abcdeghijklmnortuvyz]|t(?:[cdfghjklmnoprtvwz]|(?:rav)?el)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])\b){1,2}$'; | ||
8 | - | ||
9 | - /// URL regex | ||
10 | - Pattern url = | ||
11 | - r"^((((H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9].)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$"; | ||
12 | - | ||
13 | - /// Phone Number regex | ||
14 | - /// Must started by either, "0", "+", "+XX <X between 2 to 4 digit>", "(+XX <X between 2 to 3 digit>)" | ||
15 | - /// Can add whitespace separating digit with "+" or "(+XX)" | ||
16 | - /// Example: 05555555555, +555 5555555555, (+123) 5555555555, (555) 5555555555, +5555 5555555555 | ||
17 | - Pattern phone = | ||
18 | - r'^(0|\+|(\+[0-9]{2,4}|\(\+?[0-9]{2,4}\)) ?)([0-9]*|\d{2,4}-\d{2,4}(-\d{2,4})?)$'; | ||
19 | - | ||
20 | - /// Hexadecimal regex | ||
21 | - Pattern hexadecimal = r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'; | ||
22 | - | ||
23 | - /// Image vector regex | ||
24 | - Pattern vector = r'.(svg)$'; | ||
25 | - | ||
26 | - /// Image regex | ||
27 | - Pattern image = r'.(jpeg|jpg|gif|png|bmp)$'; | ||
28 | - | ||
29 | - /// Audio regex | ||
30 | - Pattern audio = r'.(mp3|wav|wma|amr|ogg)$'; | ||
31 | - | ||
32 | - /// Video regex | ||
33 | - Pattern video = r'.(mp4|avi|wmv|rmvb|mpg|mpeg|3gp)$'; | ||
34 | - | ||
35 | - /// Txt regex | ||
36 | - Pattern txt = r'.txt$'; | ||
37 | - | ||
38 | - /// Document regex | ||
39 | - Pattern doc = r'.(doc|docx)$'; | ||
40 | - | ||
41 | - /// Excel regex | ||
42 | - Pattern excel = r'.(xls|xlsx)$'; | ||
43 | - | ||
44 | - /// PPT regex | ||
45 | - Pattern ppt = r'.(ppt|pptx)$'; | ||
46 | - | ||
47 | - /// Document regex | ||
48 | - Pattern apk = r'.apk$'; | ||
49 | - | ||
50 | - /// PDF regex | ||
51 | - Pattern pdf = r'.pdf$'; | ||
52 | - | ||
53 | - /// HTML regex | ||
54 | - Pattern html = r'.html$'; | ||
55 | - | ||
56 | - /// DateTime regex (UTC) | ||
57 | - /// Unformatted date time (UTC and Iso8601) | ||
58 | - /// Example: 2020-04-27 08:14:39.977, 2020-04-27T08:14:39.977, 2020-04-27 01:14:39.977Z | ||
59 | - Pattern basicDateTime = r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}.\d{3}Z?$'; | ||
60 | - | ||
61 | - /// Binary regex | ||
62 | - /// Consist only 0 & 1 | ||
63 | - Pattern binary = r'^[0-1]*$'; | ||
64 | - | ||
65 | - /// MD5 regex | ||
66 | - Pattern md5 = r'^[a-f0-9]{32}$'; | ||
67 | - | ||
68 | - /// SHA1 regex | ||
69 | - Pattern sha1 = r'(([A-Fa-f0-9]{2}\:){19}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{40})'; | ||
70 | - | ||
71 | - /// SHA256 regex | ||
72 | - Pattern sha256 = r'([A-Fa-f0-9]{2}\:){31}[A-Fa-f0-9]{2}|[A-Fa-f0-9]{64}'; | ||
73 | - | ||
74 | - /// SSN (Social Security Number) regex | ||
75 | - Pattern ssn = | ||
76 | - r'^(?!0{3}|6{3}|9[0-9]{2})[0-9]{3}-?(?!0{2})[0-9]{2}-?(?!0{4})[0-9]{4}$'; | ||
77 | - | ||
78 | - /// IPv4 regex | ||
79 | - Pattern ipv4 = r'^(?:(?:^|\.)(?:2(?:5[0-5]|[0-4]\d)|1?\d?\d)){4}$'; | ||
80 | - | ||
81 | - /// IPv6 regex | ||
82 | - Pattern ipv6 = | ||
83 | - r'^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$'; | ||
84 | - | ||
85 | - /// ISBN 10 & 13 regex | ||
86 | - Pattern isbn = | ||
87 | - r'(ISBN(\-1[03])?[:]?[ ]?)?(([0-9Xx][- ]?){13}|([0-9Xx][- ]?){10})'; | ||
88 | - | ||
89 | - /// Passport No. regex | ||
90 | - Pattern passport = r'^(?!^0+$)[a-zA-Z0-9]{6,9}$'; | ||
91 | - | ||
92 | - /// Currency regex | ||
93 | - Pattern currency = | ||
94 | - r'^(S?\$|\₩|Rp|\¥|\€|\₹|\₽|fr|R$|R)?[ ]?[-]?([0-9]{1,3}[,.]([0-9]{3}[,.])*[0-9]{3}|[0-9]+)([,.][0-9]{1,2})?( ?(USD?|AUD|NZD|CAD|CHF|GBP|CNY|EUR|JPY|IDR|MXN|NOK|KRW|TRY|INR|RUB|BRL|ZAR|SGD|MYR))?$'; | ||
95 | - | ||
96 | - /// Numeric Only regex (No Whitespace & Symbols) | ||
97 | - Pattern numericOnly = r'^\d+$'; | ||
98 | - | ||
99 | - /// Alphabet Only regex (No Whitespace & Symbols) | ||
100 | - Pattern alphabetOnly = r'^[a-zA-Z]+$'; | ||
101 | - | ||
102 | - /// Password (Easy) Regex | ||
103 | - /// Allowing all character except 'whitespace' | ||
104 | - /// Minimum character: 8 | ||
105 | - Pattern passwordEasy = r'^\S{8,}$'; | ||
106 | - | ||
107 | - /// Password (Easy) Regex | ||
108 | - /// Allowing all character | ||
109 | - /// Minimum character: 8 | ||
110 | - Pattern passwordEasyAllowedWhitespace = r'^[\S ]{8,}$'; | ||
111 | - | ||
112 | - /// Password (Normal) Regex | ||
113 | - /// Allowing all character except 'whitespace' | ||
114 | - /// Must contains at least: 1 letter & 1 number | ||
115 | - /// Minimum character: 8 | ||
116 | - Pattern passwordNormal1 = r'^(?=.*[A-Za-z])(?=.*\d)\S{8,}$'; | ||
117 | - | ||
118 | - /// Password (Normal) Regex | ||
119 | - /// Allowing all character | ||
120 | - /// Must contains at least: 1 letter & 1 number | ||
121 | - /// Minimum character: 8 | ||
122 | - Pattern passwordNormal1AllowedWhitespace = | ||
123 | - r'^(?=.*[A-Za-z])(?=.*\d)[\S ]{8,}$'; | ||
124 | - | ||
125 | - /// Password (Normal) Regex | ||
126 | - /// Allowing LETTER and NUMBER only | ||
127 | - /// Must contains at least: 1 letter & 1 number | ||
128 | - /// Minimum character: 8 | ||
129 | - Pattern passwordNormal2 = r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9]{8,}$'; | ||
130 | - | ||
131 | - /// Password (Normal) Regex | ||
132 | - /// Allowing LETTER and NUMBER only | ||
133 | - /// Must contains: 1 letter & 1 number | ||
134 | - /// Minimum character: 8 | ||
135 | - Pattern passwordNormal2AllowedWhitespace = | ||
136 | - r'^(?=.*[A-Za-z])(?=.*\d)[a-zA-Z0-9 ]{8,}$'; | ||
137 | - | ||
138 | - /// Password (Normal) Regex | ||
139 | - /// Allowing all character except 'whitespace' | ||
140 | - /// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number | ||
141 | - /// Minimum character: 8 | ||
142 | - Pattern passwordNormal3 = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)\S{8,}$'; | ||
143 | - | ||
144 | - /// Password (Normal) Regex | ||
145 | - /// Allowing all character | ||
146 | - /// Must contains at least: 1 uppercase letter, 1 lowecase letter & 1 number | ||
147 | - /// Minimum character: 8 | ||
148 | - Pattern passwordNormal3AllowedWhitespace = | ||
149 | - r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\S ]{8,}$'; | ||
150 | - | ||
151 | - /// Password (Hard) Regex | ||
152 | - /// Allowing all character except 'whitespace' | ||
153 | - /// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol) | ||
154 | - /// Minimum character: 8 | ||
155 | - Pattern passwordHard = r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])\S{8,}$'; | ||
156 | - | ||
157 | - /// Password (Hard) Regex | ||
158 | - /// Allowing all character | ||
159 | - /// Must contains at least: 1 uppercase letter, 1 lowecase letter, 1 number, & 1 special character (symbol) | ||
160 | - /// Minimum character: 8 | ||
161 | - Pattern passwordHardAllowedWhitespace = | ||
162 | - r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[\S ]{8,}$'; | ||
163 | -} |
-
Please register or login to post a comment