Skip to content

Examples

Below are examples demonstrating different scenarios using the Or operator, including combinations with the Not operator and multiple Or conditions in sequence. These examples illustrate how you can tailor complex validation logic to suit your needs.

// Validation with two valid OR conditions
v = Is(Bool(true).True().Or().True())
assert.True(t, v.Valid())
// Validation with a valid OR condition followed by an invalid AND condition
v = Is(Bool(true).False().Or().True().False())
assert.False(t, v.Valid())
// Validation combining NOT and OR operators
v = Is(Bool(true).Not().False().Or().False())
assert.True(t, v.Valid())

These examples are intended to provide a clear understanding of how to effectively use the Or operator in your validations. By leveraging this functionality, you can create more flexible and powerful validation rules, enhancing the robustness and usability of your applications.