{"id":14067616,"url":"https://github.com/data-cleaning/validatedb","last_synced_at":"2025-10-22T04:49:48.631Z","repository":{"id":56934564,"uuid":"312114131","full_name":"data-cleaning/validatedb","owner":"data-cleaning","description":"Validate on a table in a DB, using dbplyr","archived":false,"fork":false,"pushed_at":"2022-06-03T14:11:33.000Z","size":638,"stargazers_count":33,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T15:27:22.312Z","etag":null,"topics":["database","datacleaning","validation"],"latest_commit_sha":null,"homepage":"https://data-cleaning.github.io/validatedb","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/data-cleaning.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-11T23:18:56.000Z","updated_at":"2024-11-12T13:27:12.000Z","dependencies_parsed_at":"2022-08-21T06:50:46.807Z","dependency_job_id":null,"html_url":"https://github.com/data-cleaning/validatedb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/data-cleaning/validatedb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-cleaning%2Fvalidatedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-cleaning%2Fvalidatedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-cleaning%2Fvalidatedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-cleaning%2Fvalidatedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/data-cleaning","download_url":"https://codeload.github.com/data-cleaning/validatedb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/data-cleaning%2Fvalidatedb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267798625,"owners_count":24145727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","datacleaning","validation"],"created_at":"2024-08-13T07:05:41.493Z","updated_at":"2025-10-22T04:49:43.608Z","avatar_url":"https://github.com/data-cleaning.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n  \n# validatedb\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/validatedb)](https://CRAN.R-project.org/package=validatedb)\n[![R build status](https://github.com/data-cleaning/validatedb/workflows/R-CMD-check/badge.svg)](https://github.com/data-cleaning/validatedb/actions)\n[![Codecov test\ncoverage](https://codecov.io/gh/data-cleaning/validatedb/branch/master/graph/badge.svg)](https://codecov.io/gh/data-cleaning/validatedb?branch=master)\n[![Mentioned in Awesome Official Statistics ](https://awesome.re/mentioned-badge.svg)](http://www.awesomeofficialstatistics.org)\n\u003c!-- badges: end --\u003e\n\n`validatedb` executes validation checks written with R package `validate` on a \ndatabase. This allows for checking the validity of records in a database.\n\n## Installation\n\nYou can install a development version with \n\n\u003c!-- You can install the released version of validatedb from [CRAN](https://CRAN.R-project.org) with: --\u003e\n\n``` r\nremotes::install_github(\"data-cleaning/validatedb\")\n```\n\n## Example\n\n```{r example}\nlibrary(validatedb)\n```\n\nFirst we setup a table in a database (for demo purpose)\n```{r}\n# create a table in a database\nincome \u003c- data.frame(id=1:2, age=c(12,35), salary = c(1000,NA))\ncon \u003c- DBI::dbConnect(RSQLite::SQLite())\nDBI::dbWriteTable(con, \"income\", income)\n```\n\nWe retrieve a reference/handle to the table in the DB with `dplyr`\n\n```{r}\ntbl_income \u003c- tbl(con, \"income\")\nprint(tbl_income)\n```\n\nLet's define a rule set and confront the table with it:\n```{r}\nrules \u003c- validator( is_adult   = age \u003e= 18\n                  , has_income = salary \u003e 0\n                  , mean_age   = mean(age,na.rm=TRUE) \u003e 24\n                  , has_values = is_complete(age, salary)\n                  )\n\n# and confront!\ncf \u003c- confront(tbl_income, rules, key = \"id\")\n\nprint(cf)\n\nsummary(cf)\n```\n\nValues (i.e. validations on the table) can be retrieved like in `validate` with\n`type=\"matrix\"` or `type=\"list\"`\n\n```{r}\nvalues(cf, type = \"matrix\")\n```\n\nBut often this seems more handy:\n\n```{r}\nvalues(cf, type = \"tbl\")\n```\n\nor \n\n```{r}\nvalues(cf, type = \"tbl\", sparse=TRUE)\n```\n\nWe can see the sql code by using `show_query`:\n\n```{r}\nshow_query(cf)\n```\n\nOr write the sql to a file for documentation (and inspiration)\n\n```{r, eval = FALSE}\ndump_sql(cf, \"validation.sql\")\n```\n\n```sql\n```{r, echo = FALSE, results=\"asis\"}\ndump_sql(cf)\n```\n```\n\n\n### Aggregate example\n\n```{r aggregate, code = readLines(\"./example/aggregate.R\")}\n\n```\n\n## validate specific functions\n\n\n### Added:\n\n- [x] `is_complete`, `all_complete`\n- [x] `is_unique`, `all_unique`\n- [x] `exists_any`, `exists_one`\n- [x] `do_by`, `sum_by`, `mean_by`, `min_by`, `max_by` \n\n### Todo\nSome newly added `validate` utility functions are (still) missing from `validatedb`.\n\n- [ ] `contains_exactly`\n- [ ] `is_linear_sequence`\n- [ ] `hierachy`\n\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdata-cleaning%2Fvalidatedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdata-cleaning%2Fvalidatedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdata-cleaning%2Fvalidatedb/lists"}