Skip to content

Commit

Permalink
Assert shorter equal fix (#15)
Browse files Browse the repository at this point in the history
* assert_shorter replaced with assert_shorter_le

* version bump to 1.0.0b6
  • Loading branch information
o-murphy authored Dec 26, 2024
1 parent 09d8d92 commit d0312c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0b5
1.0.0b6
22 changes: 11 additions & 11 deletions src/a7p/spec_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def wrapper(*args, **kwargs):

# assertion methods section
@assert_spec_type(str)
def assert_shorter(string: str, max_len: int) -> SpecValidationResult:
def assert_shorter_le(string: str, max_len: int) -> SpecValidationResult:
"""
Asserts that the length of a string is shorter than the specified maximum length.
Expand All @@ -134,7 +134,7 @@ def assert_shorter(string: str, max_len: int) -> SpecValidationResult:
SpecValidationResult: A tuple containing a boolean indicating whether the string is shorter than max_len,
and an error message if not.
"""
return len(string) < max_len, f"expected string shorter than {max_len} characters"
return len(string) <= max_len, f"expected string shorter than {max_len} characters"


@assert_spec_type(float, int)
Expand Down Expand Up @@ -319,42 +319,42 @@ def validate(self, data: Any, path: Path = Path("~/"), violations: Optional[List
# Default validation functions section
def _check_profile_name(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the profile name is shorter than 50 characters."""
return assert_shorter(x, 50)
return assert_shorter_le(x, 50)


def _check_cartridge_name(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the cartridge name is shorter than 50 characters."""
return assert_shorter(x, 50)
return assert_shorter_le(x, 50)


def _check_caliber(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the caliber name is shorter than 50 characters."""
return assert_shorter(x, 50)
return assert_shorter_le(x, 50)


def _check_bullet_name(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the bullet name is shorter than 50 characters."""
return assert_shorter(x, 50)
return assert_shorter_le(x, 50)


def _check_device_uuid(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the device UUID is shorter than 50 characters."""
return assert_shorter(x, 50)
return assert_shorter_le(x, 50)


def _check_short_name_top(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the short name (top) is shorter than 8 characters."""
return assert_shorter(x, 8)
return assert_shorter_le(x, 8)


def _check_short_name_bot(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the short name (bottom) is shorter than 8 characters."""
return assert_shorter(x, 8)
return assert_shorter_le(x, 8)


def _check_user_note(x: str, *args: Any, **kwargs: Any) -> SpecValidationResult:
"""Validates that the user note is shorter than 1024 characters."""
return assert_shorter(x, 1024)
return assert_shorter_le(x, 1024)


def _check_zero_x(x: float, *args: Any, **kwargs: Any) -> SpecValidationResult:
Expand Down Expand Up @@ -759,7 +759,7 @@ def validate_spec(payload: profedit_pb2.Payload) -> None:
'validate_spec',
'assert_spec_type',
'assert_items_count',
'assert_shorter',
'assert_shorter_le',
'assert_float_range',
'assert_int_range',
'assert_choice',
Expand Down

0 comments on commit d0312c2

Please sign in to comment.