Skip to content

Add len checker for exact length #207

Description

@cinar

Proposal

min-len/max-len exist but there's no single-tag way to require an exact length (phone numbers, fixed-width codes, postal codes). Add len:

  • Tag syntax: checkers:"len:10"
  • Applies to strings, slices, and maps, matching how min-len/max-len already handle those kinds
  • Register a schema_maker.go mapping: len:NminLength/maxLength both set to N (or minItems/maxItems, minProperties/maxProperties depending on kind, mirroring how min-len/max-len already branch)
  • Add error code + message to all 23 locale files
  • 100% test coverage; CHANGELOG.md entry

Follow the established checker file pattern (see min_len.go, max_len.go).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions