Skip to content

Add integer validators - #1728

Merged
Naramsim merged 10 commits into
masterfrom
validators-int
Nov 19, 2026
Merged

Naramsim merged 10 commits into
masterfrom
validators-int

Conversation

@Naramsim

@Naramsim Naramsim commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Change description

by Adding validators we have two benefits:

  1. stricter data contributions checks. If a not valid value is added in the CSV files, the build fails.
  2. validators ranges are expressed in the openapi schema and can be viewed in the new docs
  3. small footprint gain while building the DB

AI coding assistance disclosure

Contributor check list

  • I have written a description of the contribution and explained its motivation.
  • I have written tests for my code changes (if applicable).
  • I have read and understood the AI Assisted Contribution guidelines.
  • I will own this change in production, and I am prepared to fix any bugs caused by my code change.

@Naramsim
Naramsim requested review from FallenDeity and jemarq04 and removed request for FallenDeity and jemarq04 November 17, 2026 08:10
@Naramsim
Naramsim marked this pull request as draft November 17, 2026 08:14
@Naramsim
Naramsim requested a review from jemarq04 November 17, 2026 09:24
@Naramsim
Naramsim marked this pull request as ready for review November 17, 2026 09:24
@Naramsim
Naramsim requested a review from FallenDeity November 17, 2026 09:24
phalt
phalt previously approved these changes Nov 17, 2026

@phalt phalt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wicked, a great guardrail to add :)

@FallenDeity FallenDeity left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add a explicit check if anything else is getting caught up too maybe a pass over data and bounds set for some might be too narrow

also i thought our build.py currently dosent trigger these validators? because only full_clean or is_valid checks run them https://docs.djangoproject.com/en/5.2/ref/forms/validation/
we tend to do bulk_create can u confirm? afaik we might be bypassing these validators

Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
@Naramsim

Naramsim commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

Hi @FallenDeity it true, most of the time the validator aren't triggered, so they do act as a guardrail. They are still useful to generate the openapi schema with correct ranges for integer. I'd still merge in this PR. I fixed your and @jemarq04 suggestions, thanks a lot for going through all the values!

Would it be better to add a comment specifying that the validator are bypassed?

PS: here the only time it actually failed because a value was out of range

jemarq04
jemarq04 previously approved these changes Nov 18, 2026
Comment thread pokemon_v2/models.py Resolved
Comment thread pokemon_v2/models.py Resolved
@Naramsim
Naramsim merged commit 193d8d4 into master Nov 19, 2026
32 checks passed
@pokeapi-machine-user

Copy link
Copy Markdown

A PokeAPI/api-data refresh has started. In ~45 minutes the staging branch of PokeAPI/api-data will be pushed with the new generated data.

The staging branch will be deployed in our staging environment and the entire API will be ready to review.

A Pull Request (master<-staging) will be also created at PokeAPI/api-data and assigned to the PokeAPI Core team to be reviewed. If approved and merged new data will soon be available worldwide at pokeapi.co.

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.

5 participants