Skip to content

Commit 3c4dc84

Browse files
committed
Block divide by 0
1 parent ed20156 commit 3c4dc84

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

templates/deno/src/operator.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class Operator {
209209
* @returns {string}
210210
*/
211211
static arrayFilter = (condition: Condition, value?: any): string => {
212-
const values: any[] = [condition.valueOf()];
212+
const values: any[] = [condition as string];
213213
if (value !== undefined) {
214214
values.push(value);
215215
}

templates/dotnet/Package/Operator.cs.twig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ namespace {{ spec.title | caseUcfirst }}
4242
Condition.LessThan => "lessThan",
4343
Condition.LessThanEqual => "lessThanEqual",
4444
Condition.Contains => "contains",
45+
Condition.IsNull => "isNull",
46+
Condition.IsNotNull => "isNotNull",
4547
_ => throw new ArgumentOutOfRangeException(nameof(condition), condition, null)
4648
};
4749
}
@@ -139,11 +141,19 @@ namespace {{ spec.title | caseUcfirst }}
139141

140142
public static string ArrayAppend(List<object> values)
141143
{
144+
if (values == null)
145+
{
146+
throw new ArgumentNullException(nameof(values));
147+
}
142148
return new Operator("arrayAppend", values).ToString();
143149
}
144150

145151
public static string ArrayPrepend(List<object> values)
146152
{
153+
if (values == null)
154+
{
155+
throw new ArgumentNullException(nameof(values));
156+
}
147157
return new Operator("arrayPrepend", values).ToString();
148158
}
149159

@@ -164,11 +174,19 @@ namespace {{ spec.title | caseUcfirst }}
164174

165175
public static string ArrayIntersect(List<object> values)
166176
{
177+
if (values == null)
178+
{
179+
throw new ArgumentNullException(nameof(values));
180+
}
167181
return new Operator("arrayIntersect", values).ToString();
168182
}
169183

170184
public static string ArrayDiff(List<object> values)
171185
{
186+
if (values == null)
187+
{
188+
throw new ArgumentNullException(nameof(values));
189+
}
172190
return new Operator("arrayDiff", values).ToString();
173191
}
174192

templates/node/src/operator.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class Operator {
209209
* @returns {string}
210210
*/
211211
static arrayFilter = (condition: Condition, value?: any): string => {
212-
const values: any[] = [condition.valueOf()];
212+
const values: any[] = [condition as string];
213213
if (value !== undefined) {
214214
values.push(value);
215215
}

templates/php/src/Operator.php.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class Operator implements \JsonSerializable
117117
*/
118118
public static function modulo(int|float $divisor): string
119119
{
120+
if ($divisor === 0 || $divisor === 0.0) {
121+
throw new \InvalidArgumentException('Divisor cannot be zero');
122+
}
120123
return (new Operator('modulo', [$divisor]))->__toString();
121124
}
122125

templates/react-native/src/operator.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class Operator {
209209
* @returns {string}
210210
*/
211211
static arrayFilter = (condition: Condition, value?: any): string => {
212-
const values: any[] = [condition.valueOf()];
212+
const values: any[] = [condition as string];
213213
if (value !== undefined) {
214214
values.push(value);
215215
}

templates/web/src/operator.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class Operator {
209209
* @returns {string}
210210
*/
211211
static arrayFilter = (condition: Condition, value?: any): string => {
212-
const values: any[] = [condition.valueOf()];
212+
const values: any[] = [condition as string];
213213
if (value !== undefined) {
214214
values.push(value);
215215
}

0 commit comments

Comments
 (0)