Evgeni Chasnovski


This vignette will describe the actual validation step (called ‘exposure’) of ruler workflow and show some examples of what one can do with validation results. Packs from vignette about rule packs will be used for this.



Exposing data to rules means applying rule packs to data, collecting results in common format and attaching them to the data as an exposure attribute. In this way actual exposure can be done in multiple steps and also be a part of a general data preparation pipeline.

After attaching exposure to data frame one can extract information from it using the following functions:

For exposing data to rules use expose():

Simple example:

Don’t remove obeyers

By default exposing removes obeyers. One can leave obeyers by setting .remove_obeyers to FALSE.

Set pack name

Notice imputed group pack name group_pack__1. To change it one can set name during creation with group_packs() or write the following:

Expose step by step

One can expose to several packs at ones or do it step by step:


By default expose() guesses which type of pack function represents (if it is not set manually). This is useful for interactive experiments. Guess is based on features of pack’s output structures (see ?expose for more details).

However there are some edge cases (especially for group packs). To write strict and robust code one should use .guess = FALSE option.

Using different rule separator

If for some reason not default rule separator was used in rules() one should take this into consideration by using argument .rule_sep. It takes regular expression describing the separator. Note that by default it is a string ‘._.’ surrounded by any number of ‘non alpha-numeric characters’ (with use of inside_punct()). This is done to take account of the dplyr’s default separator _.

Acting after exposure

General actions

With exposure attached to data one can perform different kinds of actions: exploration, assertion, imputation and so on.

General actions are recommended to be done with act_after_exposure(). It takes two arguments:

If trigger didn’t notify then the input data is returned untouched. Otherwise the output of .actor() is returned. Note that act_after_exposure() is often used for creating side effects (printing, throwing error etc.) and in that case should invisibly return its input (to be able to use it with pipe %>%).

Assert presence of rule breaker

ruler has function assert_any_breaker() which can notify about presence of any breaker in exposure.