|
@@ -5,7 +5,7 @@ namespace App\Rules;
|
5
|
5
|
use Illuminate\Contracts\Validation\Rule;
|
6
|
6
|
use Illuminate\Contracts\Validation\DataAwareRule;
|
7
|
7
|
|
8
|
|
-class TWLimited implements Rule, DataAwareRule
|
|
8
|
+class RegionLimitedRules implements Rule, DataAwareRule
|
9
|
9
|
{
|
10
|
10
|
protected $data = [];
|
11
|
11
|
|
|
@@ -29,13 +29,36 @@ class TWLimited implements Rule, DataAwareRule
|
29
|
29
|
public function passes($attribute, $value)
|
30
|
30
|
{
|
31
|
31
|
//
|
32
|
|
- if (substr($value, 0, 2)=='TW') {
|
|
32
|
+ if (substr($value, 0, 2)=='TP'||substr($value, 0, 2)=='HS') {
|
|
33
|
+
|
33
|
34
|
if (is_null($this->data['registeredSession'])) {
|
34
|
35
|
return false;
|
35
|
36
|
}
|
|
37
|
+
|
36
|
38
|
if (is_null($this->data['lunchOptions'])) {
|
37
|
39
|
return false;
|
38
|
40
|
}
|
|
41
|
+
|
|
42
|
+ $pattern = '/09\d{2}-\d{3}-\d{3}/';
|
|
43
|
+ $string = $this->data['phoneNumber'];
|
|
44
|
+ if (!preg_match($pattern, $string, $matches)) {
|
|
45
|
+ return false;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ } elseif (substr($value, 0, 2)=='JP') {
|
|
49
|
+
|
|
50
|
+ $pattern = '/^0?[789](?:\d{8}|\d{9})$/';
|
|
51
|
+ $string = $this->data['phoneNumber'];
|
|
52
|
+ if (!preg_match( $pattern, $string, $matches)) {
|
|
53
|
+ return false;
|
|
54
|
+ }
|
|
55
|
+ } elseif (substr($value, 0, 2)=='KR') {
|
|
56
|
+
|
|
57
|
+ $pattern = '/^01{1}(?:\d{8,9})$/';
|
|
58
|
+ $string = $this->data['phoneNumber'];
|
|
59
|
+ if (!preg_match( $pattern, $string, $matches)) {
|
|
60
|
+ return false;
|
|
61
|
+ }
|
39
|
62
|
}
|
40
|
63
|
return true;
|
41
|
64
|
}
|