From 80e465724039a03131edb1593fdd3b67c7d98a0f Mon Sep 17 00:00:00 2001 From: Dian Bayu Nugroho Date: Tue, 6 Feb 2024 14:38:55 +0700 Subject: [PATCH] add string utils --- lib/core/utils/string_utils.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/core/utils/string_utils.dart diff --git a/lib/core/utils/string_utils.dart b/lib/core/utils/string_utils.dart new file mode 100644 index 0000000..307fb19 --- /dev/null +++ b/lib/core/utils/string_utils.dart @@ -0,0 +1,16 @@ +class StringUtils { + static bool emailValidation(String email) { + return RegExp( + 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,}))$') + .hasMatch(email); + } + + static bool phoneValidation(String phone) { + return RegExp(r'^(\+62|62|0)8[1-9][0-9]{6,10}$').hasMatch(phone); + } + + static bool passwordValidation(String password) { + return RegExp(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*?[\W_])(?=.{8,})') + .hasMatch(password); + } +}