Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UK postcode specification regex #594

Open
2 tasks done
chrisbrownlie opened this issue Feb 5, 2025 · 0 comments
Open
2 tasks done

UK postcode specification regex #594

chrisbrownlie opened this issue Feb 5, 2025 · 0 comments
Assignees

Comments

@chrisbrownlie
Copy link

Prework

Description

The UK postcode specification for col_vals_within_spec(..., spec = "postal[GB]") does not correctly validate postcodes. Maybe a regex problem related to the answer here?

Reproducible example

library(pointblank)
pst <- data.frame(
  postcodes = c("ST18 9AT", 
                "RH15 0EG",  
                "HP18 9NG", 
                "CT14 0NW",
                "TD15 2XQ", 
                "LL30 1RD", 
                "TW20 0YJ"
  )
)

agent <- pst |>
  create_agent() |>
  col_vals_within_spec(postcodes, spec = "postal[GB]") |>
  interrogate()
agent$validation_set[c("i", "n_passed", "n_failed")]
#> # A tibble: 1 × 3
#>       i n_passed n_failed
#>   <int>    <dbl>    <dbl>
#> 1     1        0        7

Created on 2025-02-05 with reprex v2.1.0

Expected result

All the postcodes above should pass as they are valid UK postcodes (can verify that here.)

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14 ucrt)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United Kingdom.utf8
#>  ctype    English_United Kingdom.utf8
#>  tz       Europe/London
#>  date     2025-02-05
#>  pandoc   3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P blastula      0.3.5   2024-02-24 [?] CRAN (R 4.4.2)
#>  P cli           3.6.3   2024-06-21 [?] RSPM (R 4.4.0)
#>  P digest        0.6.35  2024-03-11 [?] RSPM (R 4.4.0)
#>  P dplyr         1.1.4   2023-11-17 [?] RSPM
#>  P evaluate      0.23    2023-11-01 [?] RSPM (R 4.4.0)
#>  P fansi         1.0.6   2023-12-08 [?] RSPM (R 4.4.0)
#>  P fastmap       1.2.0   2024-05-15 [?] RSPM (R 4.4.0)
#>  P fs            1.6.5   2024-10-30 [?] CRAN (R 4.4.1)
#>  P generics      0.1.3   2022-07-05 [?] RSPM (R 4.4.0)
#>  P glue          1.8.0   2024-09-30 [?] RSPM
#>  P htmltools     0.5.8.1 2024-04-04 [?] RSPM (R 4.4.0)
#>  P knitr         1.46    2024-04-06 [?] RSPM (R 4.4.0)
#>  P lifecycle     1.0.4   2023-11-07 [?] RSPM (R 4.4.0)
#>  P magrittr      2.0.3   2022-03-30 [?] RSPM
#>  P pillar        1.9.0   2023-03-22 [?] RSPM (R 4.4.0)
#>  P pkgconfig     2.0.3   2019-09-22 [?] RSPM (R 4.4.0)
#>  P pointblank  * 0.12.2  2024-10-23 [?] CRAN (R 4.4.2)
#>  P purrr         1.0.2   2023-08-10 [?] RSPM
#>  P R.cache       0.16.0  2022-07-21 [?] CRAN (R 4.4.2)
#>    R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.4.0)
#>    R.oo          1.26.0  2024-01-24 [1] CRAN (R 4.4.0)
#>    R.utils       2.12.3  2023-11-18 [1] CRAN (R 4.4.1)
#>  P R6            2.5.1   2021-08-19 [?] RSPM (R 4.4.0)
#>  P reprex        2.1.0   2024-01-11 [?] RSPM (R 4.4.0)
#>  P rlang         1.1.5   2025-01-17 [?] RSPM
#>  P rmarkdown     2.27    2024-05-17 [?] RSPM (R 4.4.0)
#>  P rstudioapi    0.17.1  2024-10-22 [?] CRAN (R 4.4.1)
#>  P sessioninfo   1.2.2   2021-12-06 [?] RSPM (R 4.4.0)
#>  P styler        1.10.3  2024-04-07 [?] CRAN (R 4.4.2)
#>  P tibble        3.2.1   2023-03-20 [?] RSPM (R 4.4.0)
#>  P tidyselect    1.2.1   2024-03-11 [?] RSPM (R 4.4.0)
#>  P utf8          1.2.4   2023-10-22 [?] RSPM (R 4.4.0)
#>  P vctrs         0.6.5   2023-12-01 [?] RSPM (R 4.4.0)
#>  P withr         3.0.2   2024-10-28 [?] RSPM (R 4.4.0)
#>  P xfun          0.44    2024-05-15 [?] RSPM (R 4.4.0)
#>  P yaml          2.3.8   2023-12-11 [?] RSPM (R 4.4.0)
#> 
#>  [1] C:/Users/CBROWNLIE/AppData/Local/R/cache/R/renv/library/DN4SPrep-b73ab450/windows/R-4.4/x86_64-w64-mingw32
#>  [2] C:/Users/CBROWNLIE/AppData/Local/R/cache/R/renv/sandbox/windows/R-4.4/x86_64-w64-mingw32/a5d5c0c8
#>  [3] C:/Users/CBROWNLIE/AppData/Local/Programs/R/R-4.4.1/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants