Skip to content

Commit 6df3a76

Browse files
committed
Python check numeric range validations
1 parent 1499bc4 commit 6df3a76

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/styx/backend/python/languageprovider.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def _not_is_instance(pytype: str):
867867
func.body.extend(
868868
indent(
869869
_check_error(
870-
f"len({get_param_or_die}) == {p.list_.count_min}",
870+
f"len({get_param_or_die}) != {p.list_.count_min}",
871871
f"Parameter `{p.base.name}` must contain exactly {p.list_.count_min} element{'s' if p.list_.count_min != 1 else ''}",
872872
),
873873
level,
@@ -877,7 +877,7 @@ def _not_is_instance(pytype: str):
877877
func.body.extend(
878878
indent(
879879
_check_error(
880-
f"{p.list_.count_min} <= len({get_param_or_die}) <= {p.list_.count_max}",
880+
f"not ({p.list_.count_min} <= len({get_param_or_die}) <= {p.list_.count_max})",
881881
f"Parameter `{p.base.name}` must contain between {p.list_.count_min} and {p.list_.count_max} elements (inclusive)",
882882
),
883883
level,
@@ -887,7 +887,7 @@ def _not_is_instance(pytype: str):
887887
func.body.extend(
888888
indent(
889889
_check_error(
890-
f"len({get_param_or_die}) <= {p.list_.count_max}",
890+
f"len({get_param_or_die}) > {p.list_.count_max}",
891891
f"Parameter `{p.base.name}` must contain at most {p.list_.count_max} element{'s' if p.list_.count_max != 1 else ''}",
892892
),
893893
level,
@@ -897,7 +897,7 @@ def _not_is_instance(pytype: str):
897897
func.body.extend(
898898
indent(
899899
_check_error(
900-
f"len({get_param_or_die}) >= {p.list_.count_min}",
900+
f"len({get_param_or_die}) < {p.list_.count_min}",
901901
f"Parameter `{p.base.name}` must contain at least {p.list_.count_min} element{'s' if p.list_.count_min != 1 else ''}",
902902
),
903903
level,
@@ -929,7 +929,7 @@ def _not_is_instance(pytype: str):
929929
func.body.extend(
930930
indent(
931931
_check_error(
932-
f"{p.body.min_value} <= {get_param_or_die} <= {p.body.max_value}",
932+
f"not ({p.body.min_value} <= {get_param_or_die} <= {p.body.max_value})",
933933
f"Parameter `{p.base.name}` must be between {p.body.min_value} and {p.body.max_value} (inclusive)",
934934
),
935935
level,
@@ -939,7 +939,7 @@ def _not_is_instance(pytype: str):
939939
func.body.extend(
940940
indent(
941941
_check_error(
942-
f"{get_param_or_die} >= {p.body.min_value}",
942+
f"{get_param_or_die} < {p.body.min_value}",
943943
f"Parameter `{p.base.name}` must be at least {p.body.min_value}",
944944
),
945945
level,
@@ -949,7 +949,7 @@ def _not_is_instance(pytype: str):
949949
func.body.extend(
950950
indent(
951951
_check_error(
952-
f"{get_param_or_die} <= {p.body.max_value}",
952+
f"{get_param_or_die} > {p.body.max_value}",
953953
f"Parameter `{p.base.name}` must be at most {p.body.max_value}",
954954
),
955955
level,
@@ -964,7 +964,7 @@ def _not_is_instance(pytype: str):
964964
func.body.extend(
965965
indent(
966966
_check_error(
967-
f"{p.body.min_value} <= {get_param_or_die} <= {p.body.max_value}",
967+
f"not ({p.body.min_value} <= {get_param_or_die} <= {p.body.max_value})",
968968
f"Parameter `{p.base.name}` must be between {p.body.min_value} and {p.body.max_value} (inclusive)",
969969
),
970970
level,
@@ -974,7 +974,7 @@ def _not_is_instance(pytype: str):
974974
func.body.extend(
975975
indent(
976976
_check_error(
977-
f"{get_param_or_die} >= {p.body.min_value}",
977+
f"{get_param_or_die} < {p.body.min_value}",
978978
f"Parameter `{p.base.name}` must be at least {p.body.min_value}",
979979
),
980980
level,
@@ -984,7 +984,7 @@ def _not_is_instance(pytype: str):
984984
func.body.extend(
985985
indent(
986986
_check_error(
987-
f"{get_param_or_die} <= {p.body.max_value}",
987+
f"{get_param_or_die} > {p.body.max_value}",
988988
f"Parameter `{p.base.name}` must be at most {p.body.max_value}",
989989
),
990990
level,

0 commit comments

Comments
 (0)