The @check attribute in BAML adds validations without raising exceptions if they fail. This allows the validations to be inspected at runtime.

Usage

Field Check

BAML
1class Foo {
2 bar int @check(less_than_zero, {{ this < 0 }})
3}

Block check

1class Bar {
2 baz int
3 quux string
4 @@check(quux_limit, {{ this.quux|length < this.baz }})
5}

Benefits

  • Non-Intrusive Validation: Allows for validation checks without interrupting the flow of data processing.
  • Runtime Inspection: Enables inspection of validation results at runtime.

See more in validations guide.