mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
261 stars 30 forks source link

Can assertCharacter be used to check for non allowed symbols in string? #232

Open emantzo opened 2 years ago

emantzo commented 2 years ago

Hi! How could I use assertCharacter to check if a string contains any element that is not allowed? For example , I want to make sure that the string vector contains only letters.

Is it possible? Thank you!

tdeenes commented 2 years ago

See the pattern argument, e.g.:

checkmate::assert_character(c("a", "a123"), pattern = "^[[:alpha:]]+$")