existence rule type checks for the presence of specific tokens or patterns in your text. This is one of the simplest and most commonly used rule types in Vale.
How It Works
Theexistence rule looks for any matches of specified tokens or regular expression patterns in the provided text. When a match is found, it triggers an alert.
Parameters
An array of strings or regular expressions to match against. Each token is treated as a separate pattern to look for.
Makes all matches case-insensitive when set to
true.Removes the default word boundaries (
\b) when set to true. This allows you to match tokens that are part of larger words.An array of strings or regex patterns to be ignored. Matches that are in the exceptions list will not trigger alerts.
If
true, Vale will use your vocabulary files (accept.txt) as additional exceptions.An array of raw regex strings that will be concatenated directly into the pattern without modification.
Examples
Basic Word List
Check for overly technical acronyms that should be expanded:E-Prime Style
Check for forms of “to be” to encourage more active writing:Using Exceptions
Check for problematic terms while allowing specific exceptions:Pattern Matching with Nonword
Match patterns that aren’t complete words:Use Cases
The
existence rule is ideal for:- Maintaining word blocklists
- Enforcing style guidelines about specific terms
- Preventing deprecated terminology
- Checking for brand name misuse
- Enforcing inclusive language
Technical Details
Internally, theexistence rule (internal/check/existence.go:73-97):
- Compiles all tokens into a single regular expression pattern
- Searches the text for all matches using
FindAllStringIndex - For each match, checks if it’s in the exceptions list
- Creates an alert for any match that’s not an exception
ignorecase and nonword settings, automatically adding word boundaries unless nonword is true.
Related Rule Types
- substitution: Use when you want to suggest replacements for matched tokens
- occurrence: Use when you want to count how many times a token appears
- repetition: Use when you want to detect repeated words