Skip to content

R validators with pretty output#97

Merged
jeanetteclark merged 19 commits intodevelopfrom
feature-79-validation
Mar 27, 2026
Merged

R validators with pretty output#97
jeanetteclark merged 19 commits intodevelopfrom
feature-79-validation

Conversation

@jeanetteclark
Copy link
Copy Markdown
Collaborator

This PR contains 5 validation functions that mirror the vb_upload family of functions.

  • vb_validate_plot_observations
  • vb_validate_plant_concepts
  • vb_validate_community_concepts
  • vb_validate_stratum_methods
  • vb_validate_cover_methods

These functions do fairly minimal checking for:

  • no nulls
  • no duplicates
  • at least one present (eg: vb_py_code, user_py_code)
  • values exist (in another data frame)

so they do not do type checking or checking for controlled lists. Overall this validation is not as complete as the python validator, and certainly not what happens in postgres, but the intention is to get some user-friendly output to users where they might need it.

Failing output looks like:

ℹ plot_observations: Column 'user_parent_pl_code' not found - skipping foreign key validation
✖ community_classifications: NULL values found in vb_cc_code (9)
✖ strata_cover_data: NULL values found in author_plant_name (5)
✖ strata_cover_data.user_sr_code values not found in strata.user_sr_code: ANZA139_NA, ANZA170_NA, ANZA174_NA, ANZA175_NA, ANZA190_NA (and 1135 more)
✖ strata: NULL values found in vb_sy_code (1234)
✖ taxon_interpretations: NULL values found in vb_pc_code (7192)
ℹ soils not provided - skipping NULL validation
ℹ soils not provided - skipping duplicate validation
ℹ soils or plot_observations not provided - skipping foreign key validation

Failing output that comes from the python validator back to the R client looks like this:

• The following user_pj_code values in plot_observations do not exist: SSNF, DOLO, MOJD, SVRA, SLAV, COYO, MOLA, ALCC-GR, DEVA-Springs, SCRUZ, WLKR, CEQA_WRFB, WSD, SCLR, EBRP-GR, PWPOF, TEHA, SNI, EDGW, SNFN, CVPAA, CZPOF, SASU, OWVA-Recon, QHQ, SCR, SFVW, DEDW, EBAY, WRIV, PSMA, DRECP, MOJDchap, EBRP, CANO, LLNL, CZPOFL, ALCC, SMAT, DEVA-DelFavero, CDLO, PORE, CAVA, PVPLC, SDG, ALSC, LOMA, OWVA, SCRUZL, CVRP, PINN, SPCC, SAMO, SBVWCD, SACT, PYGM, MOJA-McAuliffe, MDEI_Central, CAMO-VegMap, SJV, MARIN, MOJA-NRCS, SCLAR, MOJA-VegMap, SNC-LARMB, MOJA-Evens, CHOC, CEQA_SWNC, ELDO, SONO, HETH, PTAR, FISH, OAKG, JAWB, KNOX, JAWB-Recon, FNWS, AWSF, CEQA_BRVC, SEKI, CPVC, CARR, PIME, SNC-MidPen, CVPA, JOMU, DEVA-Slaton, ISMT, DFGRF. The following user_sr_code values in strata_cover_data do not exist: ANZA454_NA, ANZA388_NA, ANZA403_NA, ANZA229_NA, ANZA205_NA, ANZA170_NA, ANZA443_NA, ANZA139_NA, ANZA174_NA, ANZA240_NA, ANZA495_NA, ANZA490_NA, ANZA209_NA, ANZA461_NA, ANZA203_NA, ANZA482_NA, ANZA447_NA, ANZA329_NA, ANZA485_NA, ANZA175_NA, ANZA190_NA. The following required columns for taxon_interpretations must be present with no null values : vb_pc_code.

Passing output looks like:

ℹ plot_observations: Column 'user_parent_pl_code' not found - skipping foreign key validation
ℹ soils not provided - skipping NULL validation
ℹ soils not provided - skipping duplicate validation
ℹ soils or plot_observations not provided - skipping foreign key validation
✔ All loader tables valid.

and it returns a result object, a named list with an item for each table that was passed in and whether that table passed or failed.

@jeanetteclark jeanetteclark requested a review from regetz March 25, 2026 18:29
Copy link
Copy Markdown
Collaborator

@regetz regetz left a comment

Choose a reason for hiding this comment

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

Ship it! As discussed, this is leaving some nice stubs for building this out more in the future.

@jeanetteclark jeanetteclark merged commit fb03264 into develop Mar 27, 2026
6 checks passed
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.

2 participants