Skip to content

Commit 9bdba2e

Browse files
committed
docs: add regex101.com links.
1 parent 108a73f commit 9bdba2e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

system/Validation/FormatRules.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function alpha_space(?string $value = null): bool
4444
return true;
4545
}
4646

47+
// @see https://regex101.com/r/LhqHPO/1
4748
return (bool) preg_match('/\A[A-Z ]+\z/i', $value);
4849
}
4950

@@ -56,7 +57,8 @@ public function alpha_space(?string $value = null): bool
5657
*/
5758
public function alpha_dash(?string $str = null): bool
5859
{
59-
return (bool) preg_match('/\A[a-z0-9_-]+\z/i', $str);
60+
// @see https://regex101.com/r/XfVY3d/1
61+
return (bool) preg_match('/\A[a-z0-9_-]+\z/i', $str);
6062
}
6163

6264
/**
@@ -72,6 +74,7 @@ public function alpha_dash(?string $str = null): bool
7274
*/
7375
public function alpha_numeric_punct($str)
7476
{
77+
// @see https://regex101.com/r/6N8dDY/1
7578
return (bool) preg_match('/\A[A-Z0-9 ~!#$%\&\*\-_+=|:.]+\z/i', $str);
7679
}
7780

@@ -96,6 +99,7 @@ public function alpha_numeric(?string $str = null): bool
9699
*/
97100
public function alpha_numeric_space(?string $str = null): bool
98101
{
102+
// @see https://regex101.com/r/0AZDME/1
99103
return (bool) preg_match('/\A[A-Z0-9 ]+\z/i', $str);
100104
}
101105

@@ -123,6 +127,7 @@ public function string($str = null): bool
123127
*/
124128
public function decimal(?string $str = null): bool
125129
{
130+
// @see https://regex101.com/r/HULifl/1/
126131
return (bool) preg_match('/\A[-+]?[0-9]{0,}\.?[0-9]+\z/', $str);
127132
}
128133

@@ -181,6 +186,7 @@ public function is_natural_no_zero(?string $str = null): bool
181186
*/
182187
public function numeric(?string $str = null): bool
183188
{
189+
// @see https://regex101.com/r/bb9wtr/1
184190
return (bool) preg_match('/\A[\-+]?[0-9]*\.?[0-9]+\z/', $str);
185191
}
186192

@@ -253,6 +259,7 @@ public function valid_json(string $str = null): bool
253259
*/
254260
public function valid_email(string $str = null): bool
255261
{
262+
// @see https://regex101.com/r/wlJG1t/1/
256263
if (function_exists('idn_to_ascii') && defined('INTL_IDNA_VARIANT_UTS46') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches))
257264
{
258265
$str = $matches[1] . '@' . idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46);

0 commit comments

Comments
 (0)