ValidationInfo
Provider declaring how a target should be validated.
When a target carrying ValidationInfo is reachable via a transitive
dependency edge from a target requested on the command line (e.g.
buck2 build, buck2 test), Buck2 schedules every ValidationSpec
it carries before the requested action is considered complete. A
failed required validation causes the build to fail; an optional
validation is skipped unless the user opts in via
--enable-optional-validations <name>.
Validations run in parallel with the build of the requested target — they only have to finish before Buck2 reports success.
Constraints enforced at construction / freezing time:
validationsmust be a non-empty list ofValidationSpecvalues.- Spec names must be unique within the provider.
Example:
def _my_rule_impl(ctx):
report = ctx.actions.declare_output("validation.json")
ctx.actions.run(
cmd_args("validator", "--out", report.as_output(), ctx.attrs.src),
category = "my_validation",
)
return [
DefaultInfo(default_output = ctx.attrs.src),
ValidationInfo(validations = [
ValidationSpec(name = "schema_check", validation_result = report),
]),
]
See the Validations guide for the end-to-end story.
ValidationInfo.validations
ValidationInfo.validations: list[ValidationSpec]
Non-empty list of ValidationSpec values, each representing a single validation. Spec names must be unique within this provider.
See the Validations guide
for how to declare validations end-to-end and write the validator
action that produces each spec's validation_result.