🐛 Fix FraiseQL Empty String Validation for Required Fields#53
Merged
Conversation
- Add validation to reject empty/whitespace-only strings in required string fields - Maintain backward compatibility for optional fields (str | None) - Include comprehensive unit and integration tests - Follow TDD methodology with Red→Green→Refactor→Polish phases Fixes empty string validation inconsistency issue 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the inconsistent string validation issue where FraiseQL accepted empty strings (
"") and whitespace-only strings (" ") for required string fields, while correctly rejectingnullvalues.Problem
"") were incorrectly accepted for required string fields" ") were incorrectly acceptedSolution
✅ Enhanced Input Validation
make_init()functionstr | None)_extract_type()function for proper type detectionValidation Behavior
name: str)name: str | None)null""" ""valid"Changes Made
Core Implementation
src/fraiseql/utils/fraiseql_builder.py_is_string_field()helper for string type detection_validate_string_value()for empty string validation_fraiseql_init()functionError Handling
"Field 'field_name' cannot be empty"Testing
Comprehensive Test Coverage
Test Scenarios Covered
str | None)Development Methodology
Implemented using micro-TDD cycles with Marie Kondo methodology:
Backward Compatibility
🛡️ 100% Backward Compatible
Impact
User Experience
Developer Experience
Example Usage
Test Plan
🤖 Generated with Claude Code