encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

Add validation for fixed-length strings. #621

Closed jeamland closed 5 years ago

jeamland commented 6 years ago

The error messages returned by min_length and max_length can be a little confusing (at least cosmetically) if the requirement is actually a string of a fixed length. This patch allows the specification of a length parameter to a String validator and also applies this logic if min_length==max_length.

tomchristie commented 5 years ago

Redundant given that we're now using https://github.com/encode/typesystem for the validation. (But I'd happily take a similar PR there - it'd still be valid)