Conditional rules may be constrained by the others rules in a validation rule set. This procedure tries to simplify conditional statements.

simplify_conditional(x, ...)

Arguments

x

validator object with the validation rules.

...

not used.

Value

validator simplified rule set.

References

TODO non-constraining, non-relaxing

Examples

library(validate)

# non-relaxing clause
rules <- validator( r1 = if (x > 1) y > 3
                  , r2 = y < 2
                  )
# y > 3 is always FALSE so r1 can be simplified
simplify_conditional(rules)
#> Object of class 'validator' with 2 elements:
#>  r1: x <= 1
#>  r2: y < 2

# non-constraining clause
rules <- validator( r1 = if (x > 0) y > 0
                  , r2 = if (x < 1) y > 1
                  )
simplify_conditional(rules)
#> Object of class 'validator' with 2 elements:
#>  r1: y > 0
#>  r2: x >= 1 | (y > 1)

rules <- validator( r1 = if (A == "a1") x > 0
                  , r2 = if (A == "a2") x > 1
                  , r3 = A == "a1"
                  )
simplify_conditional(rules)
#> Object of class 'validator' with 3 elements:
#>  r1: x > 0
#>  r2: A != "a2" | (x > 1)
#>  r3: A == "a1"