Skip to content

Commit a2ee991

Browse files
committed
Add Min/Max functions
1 parent ef7253e commit a2ee991

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

schemas/Max.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://www.flippercloud.io/expressions/Max.schema.json",
4+
"title": "Max",
5+
"$ref": "schema.json#/$defs/arguments(n)"
6+
}

schemas/Min.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://www.flippercloud.io/expressions/Min.schema.json",
4+
"title": "Min",
5+
"$ref": "schema.json#/$defs/arguments(n)"
6+
}

schemas/schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"GreaterThanOrEqualTo": { "$ref": "GreaterThanOrEqualTo.schema.json" },
3030
"LessThan": { "$ref": "LessThan.schema.json" },
3131
"LessThanOrEqualTo": { "$ref": "LessThanOrEqualTo.schema.json" },
32+
"Max": { "$ref": "Max.schema.json" },
33+
"Min": { "$ref": "Min.schema.json" },
3234
"NotEqual": { "$ref": "NotEqual.schema.json" },
3335
"Now": { "$ref": "Now.schema.json" },
3436
"Number": { "$ref": "Number.schema.json" },

test/examples/Max.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"valid": [
3+
{
4+
"expression": { "Max": [] },
5+
"result": { "enum": [null] }
6+
},
7+
{
8+
"expression": { "Max": [3, 2, 1] },
9+
"result": { "enum": [3] }
10+
},
11+
{
12+
"expression": { "Max": [0.1, 0.2] },
13+
"result": { "enum": [0.2] }
14+
},
15+
{
16+
"expression": { "Max": ["a", "b"] },
17+
"result": { "enum": ["b"] }
18+
},
19+
{
20+
"expression": { "Max": 100 },
21+
"result": { "enum": [100] }
22+
},
23+
{
24+
"expression": { "Max": [{ "Number": "2" }, { "Number": "1" }] },
25+
"result": { "enum": [2] }
26+
}
27+
],
28+
"invalid": [
29+
{ "Max": null },
30+
{ "Max": [], "Any": [] }
31+
]
32+
}

test/examples/Min.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"valid": [
3+
{
4+
"expression": { "Min": [] },
5+
"result": { "enum": [null] }
6+
},
7+
{
8+
"expression": { "Min": [3, 2, 1] },
9+
"result": { "enum": [1] }
10+
},
11+
{
12+
"expression": { "Min": [0.1, 0.2] },
13+
"result": { "enum": [0.1] }
14+
},
15+
{
16+
"expression": { "Min": ["a", "b"] },
17+
"result": { "enum": ["a"] }
18+
},
19+
{
20+
"expression": { "Min": 100 },
21+
"result": { "enum": [100] }
22+
},
23+
{
24+
"expression": { "Min": [{ "Number": "2" }, { "Number": "1" }] },
25+
"result": { "enum": [1] }
26+
}
27+
],
28+
"invalid": [
29+
{ "Min": null },
30+
{ "Min": [], "Any": [] }
31+
]
32+
}

0 commit comments

Comments
 (0)