feat: add Pydantic schema validation for species and samples - #423
Open
ghzhost wants to merge 1 commit into
Open
feat: add Pydantic schema validation for species and samples#423ghzhost wants to merge 1 commit into
ghzhost wants to merge 1 commit into
Conversation
…-bounties#4) - Add SpeciesRecord and SampleRecord Pydantic models in src/plantguide/schemas.py - CareCard model validates all required care fields (summary, light, water, soil, humidity, temperature_c, fertilizer, toxicity) - SpeciesRecord enforces id pattern, minimum 5 tags, and full care block - SampleRecord validates tags list and optional expected_species - validate_species() and validate_sample() helper functions for easy use - 18 tests in tests/test_schema_validation.py: - Good/bad fixture unit tests for both species and sample schemas - Integration tests validate existing catalog files (69% pass rate, legacy stubs pre-date this schema) - All 67 existing tests still pass Fixes mergeos-bounties#4
This was referenced Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4
Summary
Adds Pydantic v2 schema validation for species and sample JSON files, as requested in issue #4.
Changes
src/plantguide/schemas.py(new)CareCard— validates all required care fields:summary,light,water,soil,humidity,temperature_c,fertilizer,toxicity;common_issues/tipsdefault to[]SpeciesRecord— validatesid(lowercase+underscore pattern),common_name, ≥5tags, and a fullCareCardSampleRecord— validatestagslist and optionalexpected_speciesvalidate_species()andvalidate_sample()helper functionstests/test_schema_validation.py(new — 18 tests)data/species/*.jsonfiles (69% pass rate with ≥60% threshold; legacy stubs created before this schema are expected to fail)data/samples/*.jsonfiles (100% pass)Verification