Skip to content

Add LimitedString field with min/max constraints and automatic validation#18769

Draft
lkostrowski wants to merge 5 commits intomainfrom
limited-string
Draft

Add LimitedString field with min/max constraints and automatic validation#18769
lkostrowski wants to merge 5 commits intomainfrom
limited-string

Conversation

@lkostrowski
Copy link
Member

@lkostrowski lkostrowski commented Feb 6, 2026

Summary

  • Introduces LimitedString() — a factory function that creates graphene.String fields with min_length / max_length constraints. Constraint metadata is stored on the field and automatically propagated to BaseInputObjectType subclasses via _string_constraints.
  • Adds automatic validation in BaseMutation.mutate() and DeprecatedModelMutation that recursively validates all LimitedString constraints before perform_mutation runs — no manual validation needed in individual mutations.
  • Constraint descriptions are auto-appended to the GraphQL schema (e.g., "(maximum 250 characters.)")
  • Replaces manual string length validation across several mutations:
    • Product media: alt field (max 250)
    • Payment transactions: card name (max 256), brand (max 40), firstDigits/lastDigits (max 4), other payment method name (max 256)
    • Order bulk create: note message (max 255)

Test plan

  • Unit tests for LimitedString field factory (constraints, descriptions, assertions)
  • Unit tests for BaseInputObjectType._string_constraints propagation and inheritance
  • Unit tests for validate_string_constraints validator
  • Unit tests for BaseMutation._validate_input_string_constraints (recursive, nested, list)
  • Existing mutation tests updated to reflect new validation behavior

🤖 Generated with Claude Code

@db-queries
Copy link

db-queries bot commented Feb 6, 2026

Here is the report for 4561a82 (saleor:limited-string)
Base comparison is c900de1.

No differences were found.

@lkostrowski lkostrowski changed the title Add LimitedString field that extends String with min and max constraints Add LimitedString field with min/max constraints and automatic validation Feb 6, 2026
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