More exotic types
See original GitHub issueHi,
At my company we would like to migrate to your package, but we need more types out of the box. Below you can find list of additional types and validators and I like to discuss with you what do you think:
- Min and max length validators for list type, maybe something like
conlist(type_=..., min_length=..., max_length=...)
. Of course I can implement length validation usingvalidator
decorator, but it’s too complex to share as common type for company needs. - (Done #175) Decimal type not supported at all. Also we would like to have validators for minimum, maximum, maximum digits and decimal places like in Django (https://github.com/django/django/blob/master/django/forms/fields.py#L322, https://github.com/django/django/blob/master/django/core/validators.py#L388).
- (Done #166) Float type: minimum and maximum validators.
- String type:
- (Done #163) We need additional
strip_whitespace
argument inconstr
to strip whitespaces, justvalue.strip()
. In my opinion it’s common practice for validation libraries to have this option. - Also I would like to discuss with you coerce logic (https://github.com/samuelcolvin/pydantic/blob/master/pydantic/validators.py#L30). Why it supports only for float, int and decimal types? Can we use logic which already implemented for dict and list types (https://github.com/samuelcolvin/pydantic/blob/master/pydantic/validators.py#L83)?
- (Done #163) We need additional
- (Done #167) UUID type version validation, just
value.version == ...
.
If you are okay with my proposals, then I will create a few PRs for each my proposal.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (8 by maintainers)
Top Results From Across the Web
10 Most Exotic Weed Strains 2022
The more exotic types have different effects, they can also be stronger and have a different smell and even a different color of...
Read more >Types of Exotic Pets
There are several categories of exotic pet species: Amphibians. Most need tanks with both water and “land” for your pet to feel completely ......
Read more >EVEN MORE Types of Exotic Cat Breeds
EVEN MORE Types of Exotic Cat Breeds · #9: LaPerm · #8: Sphynx · #7: Devon Rex · #6: Maine Coon · #5:...
Read more >More exotic types · Issue #161 · pydantic ...
Below you can find list of additional types and validators and I like to discuss with you what do you think:
Read more >5 Exotic Butterfly Species from Around the World
Butterflies are some of the most beautiful creatures in the world, and many exotic butterfly species come in a wide variety of dazzling ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is not what
conlist
is for,conlist
is for controlling the size of the outer list.You can achieve what you’re looking for here either with custom validators, a
Point
type that implements it’s own validation, or with a simple tuple:If you have anymore questions, please create a new issue.
Oh I’m sorry I forgot to elaborate on my issue a bit more. In my case, I need to validate geometry objects based on the GeoJSON Specification. In my example above I validate a
Polygon
object. The structure of thePolygon
in a GeoJSON has to look like this:As you can see the coordinates are a nested list with an exterior Part (second list) and
Point
s (lists within the second list). The order of aPoint
described by the Geojson is[longitude, latitude, elevation]
. So a Point can only have either 2 or 3 values in a list but not more or less. That’s whyconlist
might come in handy because theconlist
would set a constraint on the list/array object.Would you accept a PR for GeoJSON support? Also for the
conlist
?