Skip to content

Conversation

sunnynguyen-ai
Copy link

Summary

Systematically fixes boolean return type inconsistencies across multiple validator functions.

Changes Made

  • domain.py: Wrapped re.match() result with bool() for consistent boolean return
  • ip_address.py: Wrapped IPv4Address, IPv6Address, IPv4Network, IPv6Network objects with bool()
  • mac_address.py: Wrapped re.match() result with bool()
  • uuid.py: Wrapped UUID() object and re.match() result with bool()
  • slug.py: Wrapped re.match() result with bool()

Problem Fixed

Several validators were returning truthy objects (match objects, IP address objects) instead of strict boolean values, creating inconsistencies with the @validator decorator expectations and function signatures.

Impact

  • Ensures consistent boolean return types across all validators
  • Maintains type safety and predictable behavior
  • Improves code reliability and follows documented return type signatures

Testing

All existing functionality preserved - changes only affect return type consistency, not validation logic.

Fix inconsistent boolean return types in domain validation regex check.

- Changed re.match() result to bool() for consistent boolean return
- Ensures both parts of the 'and' expression return proper booleans
- Maintains type safety and consistency with @validator decorator expectations
- Improves code reliability and predictability

This addresses a logical inconsistency where re.search() was negated (returning bool)
while re.match() returned a match object (truthy but not strictly boolean).
Wrap IPv4Address, IPv6Address, IPv4Network, and IPv6Network objects with bool() 
for consistent boolean return types.

- Ensures all validators return proper booleans instead of truthy objects
- Maintains type safety and consistency with @validator decorator expectations
- Improves predictability and follows the documented return type signatures
- Addresses inconsistent return types in IP validation functions
Wrap re.match() result with bool() for consistent boolean return type.

- Ensures MAC address validator returns proper boolean instead of match object
- Maintains consistency with other validators and @validator decorator expectations
- Part of systematic fix for boolean return type inconsistencies across validators
Wrap UUID() object and re.match() result with bool() for consistent boolean return types.

- Ensures UUID validator returns proper booleans instead of truthy objects
- Maintains consistency with other validators and @validator decorator expectations
- Part of systematic fix for boolean return type inconsistencies across validators
Wrap re.match() result with bool() for consistent boolean return type.

- Ensures slug validator returns proper boolean instead of match object
- Maintains consistency with other validators and @validator decorator expectations
- Completes systematic fix for boolean return type inconsistencies across validators
@sunnynguyen-ai sunnynguyen-ai closed this by deleting the head repository Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant