@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.001 |
9 | 9 | * Generates a JSON Rule for the validation of a field |
10 | 10 | */ |
11 | -class Rule implements \JsonSerializable{ |
|
11 | +class Rule implements \JsonSerializable { |
|
12 | 12 | /** |
13 | 13 | * @var string |
14 | 14 | */ |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | private $value; |
25 | 25 | |
26 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
26 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
27 | 27 | $this->type=$type; |
28 | 28 | $this->prompt=$prompt; |
29 | 29 | $this->value=$value; |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | |
59 | 59 | #[\ReturnTypeWillChange] |
60 | 60 | public function jsonSerialize() { |
61 | - $result= ["type"=>$this->type]; |
|
62 | - if(isset($this->prompt)) |
|
61 | + $result=["type"=>$this->type]; |
|
62 | + if (isset($this->prompt)) |
|
63 | 63 | $result["prompt"]=$this->prompt; |
64 | - if(isset($this->value)) |
|
64 | + if (isset($this->value)) |
|
65 | 65 | $result["value"]=$this->value; |
66 | 66 | return $result; |
67 | 67 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $prompt |
73 | 73 | * @return \Ajax\semantic\components\validation\Rule |
74 | 74 | */ |
75 | - public static function match($name,$prompt=NULL){ |
|
76 | - return new Rule("match[".$name."]",$prompt); |
|
75 | + public static function match($name, $prompt=NULL) { |
|
76 | + return new Rule("match[".$name."]", $prompt); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @param string $prompt |
83 | 83 | * @return \Ajax\semantic\components\validation\Rule |
84 | 84 | */ |
85 | - public static function different($name,$prompt=NULL){ |
|
86 | - return new Rule("different[".$name."]",$prompt); |
|
85 | + public static function different($name, $prompt=NULL) { |
|
86 | + return new Rule("different[".$name."]", $prompt); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,82 +93,82 @@ discard block |
||
93 | 93 | * @param string $prompt |
94 | 94 | * @return \Ajax\semantic\components\validation\Rule |
95 | 95 | */ |
96 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
97 | - if(\is_int($min) && \is_int($max)) |
|
98 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
99 | - return new Rule("integer",$prompt); |
|
96 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
97 | + if (\is_int($min) && \is_int($max)) |
|
98 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
99 | + return new Rule("integer", $prompt); |
|
100 | 100 | } |
101 | 101 | |
102 | - public static function decimal($prompt=NULL){ |
|
103 | - return new Rule("decimal",$prompt); |
|
102 | + public static function decimal($prompt=NULL) { |
|
103 | + return new Rule("decimal", $prompt); |
|
104 | 104 | } |
105 | 105 | |
106 | - public static function number($prompt=NULL){ |
|
107 | - return new Rule("number",$prompt); |
|
106 | + public static function number($prompt=NULL) { |
|
107 | + return new Rule("number", $prompt); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function is($value,$prompt=NULL){ |
|
111 | - return new Rule("is[".$value."]",$prompt); |
|
110 | + public static function is($value, $prompt=NULL) { |
|
111 | + return new Rule("is[".$value."]", $prompt); |
|
112 | 112 | } |
113 | 113 | |
114 | - public static function isExactly($value,$prompt=NULL){ |
|
115 | - return new Rule("isExactly[".$value."]",$prompt); |
|
114 | + public static function isExactly($value, $prompt=NULL) { |
|
115 | + return new Rule("isExactly[".$value."]", $prompt); |
|
116 | 116 | } |
117 | 117 | |
118 | - public static function not($value,$prompt=NULL){ |
|
119 | - return new Rule("not[".$value."]",$prompt); |
|
118 | + public static function not($value, $prompt=NULL) { |
|
119 | + return new Rule("not[".$value."]", $prompt); |
|
120 | 120 | } |
121 | 121 | |
122 | - public static function notExactly($value,$prompt=NULL){ |
|
123 | - return new Rule("notExactly[".$value."]",$prompt); |
|
122 | + public static function notExactly($value, $prompt=NULL) { |
|
123 | + return new Rule("notExactly[".$value."]", $prompt); |
|
124 | 124 | } |
125 | 125 | |
126 | - public static function contains($value,$prompt=NULL){ |
|
127 | - return new Rule("contains[".$value."]",$prompt); |
|
126 | + public static function contains($value, $prompt=NULL) { |
|
127 | + return new Rule("contains[".$value."]", $prompt); |
|
128 | 128 | } |
129 | 129 | |
130 | - public static function containsExactly($value,$prompt=NULL){ |
|
131 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
130 | + public static function containsExactly($value, $prompt=NULL) { |
|
131 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
132 | 132 | } |
133 | 133 | |
134 | - public static function doesntContain($value,$prompt=NULL){ |
|
135 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
134 | + public static function doesntContain($value, $prompt=NULL) { |
|
135 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
136 | 136 | } |
137 | 137 | |
138 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
139 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
138 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
139 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
140 | 140 | } |
141 | 141 | |
142 | - public static function minCount($value,$prompt=NULL){ |
|
143 | - return new Rule("minCount[".$value."]",$prompt); |
|
142 | + public static function minCount($value, $prompt=NULL) { |
|
143 | + return new Rule("minCount[".$value."]", $prompt); |
|
144 | 144 | } |
145 | 145 | |
146 | - public static function maxCount($value,$prompt=NULL){ |
|
147 | - return new Rule("maxCount[".$value."]",$prompt); |
|
146 | + public static function maxCount($value, $prompt=NULL) { |
|
147 | + return new Rule("maxCount[".$value."]", $prompt); |
|
148 | 148 | } |
149 | 149 | |
150 | - public static function exactCount($value,$prompt=NULL){ |
|
151 | - return new Rule("exactCount[".$value."]",$prompt); |
|
150 | + public static function exactCount($value, $prompt=NULL) { |
|
151 | + return new Rule("exactCount[".$value."]", $prompt); |
|
152 | 152 | } |
153 | 153 | |
154 | - public static function email($prompt=NULL){ |
|
155 | - return new Rule("email",$prompt); |
|
154 | + public static function email($prompt=NULL) { |
|
155 | + return new Rule("email", $prompt); |
|
156 | 156 | } |
157 | 157 | |
158 | - public static function url($prompt=NULL){ |
|
159 | - return new Rule("url",$prompt); |
|
158 | + public static function url($prompt=NULL) { |
|
159 | + return new Rule("url", $prompt); |
|
160 | 160 | } |
161 | 161 | |
162 | - public static function regExp($value,$prompt=NULL){ |
|
163 | - return new Rule("regExp",$prompt,$value); |
|
162 | + public static function regExp($value, $prompt=NULL) { |
|
163 | + return new Rule("regExp", $prompt, $value); |
|
164 | 164 | } |
165 | 165 | |
166 | - public static function custom($name,$jsFunction){ |
|
167 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
166 | + public static function custom($name, $jsFunction) { |
|
167 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
168 | 168 | } |
169 | 169 | |
170 | - public static function ajax(JsUtils $js,$name,$url,$params,$jsCallback,$method="post",$parameters=[]){ |
|
171 | - $parameters=\array_merge(["async"=>false,"url"=>$url,"params"=>$params,"hasLoader"=>false,"jsCallback"=>$jsCallback,"dataType"=>"json","stopPropagation"=>false,"preventDefault"=>false,"responseElement"=>null],$parameters); |
|
170 | + public static function ajax(JsUtils $js, $name, $url, $params, $jsCallback, $method="post", $parameters=[]) { |
|
171 | + $parameters=\array_merge(["async"=>false, "url"=>$url, "params"=>$params, "hasLoader"=>false, "jsCallback"=>$jsCallback, "dataType"=>"json", "stopPropagation"=>false, "preventDefault"=>false, "responseElement"=>null], $parameters); |
|
172 | 172 | $ajax=new AjaxCall($method, $parameters); |
173 | 173 | return self::custom($name, "function(value,ruleValue){var result=true;".$ajax->compile($js)."return result;}"); |
174 | 174 | } |
@@ -59,10 +59,12 @@ discard block |
||
59 | 59 | #[\ReturnTypeWillChange] |
60 | 60 | public function jsonSerialize() { |
61 | 61 | $result= ["type"=>$this->type]; |
62 | - if(isset($this->prompt)) |
|
63 | - $result["prompt"]=$this->prompt; |
|
64 | - if(isset($this->value)) |
|
65 | - $result["value"]=$this->value; |
|
62 | + if(isset($this->prompt)) { |
|
63 | + $result["prompt"]=$this->prompt; |
|
64 | + } |
|
65 | + if(isset($this->value)) { |
|
66 | + $result["value"]=$this->value; |
|
67 | + } |
|
66 | 68 | return $result; |
67 | 69 | } |
68 | 70 | |
@@ -94,8 +96,9 @@ discard block |
||
94 | 96 | * @return \Ajax\semantic\components\validation\Rule |
95 | 97 | */ |
96 | 98 | public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
97 | - if(\is_int($min) && \is_int($max)) |
|
98 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
99 | + if(\is_int($min) && \is_int($max)) { |
|
100 | + return new Rule("integer[{$min}..{$max}]",$prompt); |
|
101 | + } |
|
99 | 102 | return new Rule("integer",$prompt); |
100 | 103 | } |
101 | 104 |