## build_rule_checks()


Return an asset check for each of the schema's rules on [asset](asset.md#dagster_dataframely.asset), plus the column-schema check.


Usage

``` python
build_rule_checks(
    schema,
    /,
    *,
    asset,
    name=None,
    partitions_def=None,
    check_granularity=None,
    max_failure_examples=None
)
```


The checks read the asset's table through its own IO manager, as a `pl.DataFrame`, and write nothing.


## Parameters


`schema: type[dy.Schema]`  
The schema whose rules become checks.

`asset: str | dg.AssetKey`  
The key of the asset whose table the checks read, which `dd.asset` did not build.

`name: str | None = None`  
The name of the step that runs the checks. `None` uses the asset key's Python identifier followed by `__checks`, because a name built from the schema would repeat for two assets that share it, and Dagster raises on two steps with one name.

`partitions_def: dg.PartitionsDefinition | None = None`  
The asset's partitions, so each run checks one partition. Dagster does not check that it matches the asset's.

`check_granularity: Granularity | None = None`  
How many checks report the schema's rules: one per rule at `rule`, and at `column` one per column with rules plus one per schema-level rule. `None` uses `DAGSTER_DATAFRAMELY_CHECK_GRANULARITY` if set, else `rule`.

`max_failure_examples: int | None = None`  
A rule's check metadata has at most this many rows that failed it. `None` uses `DAGSTER_DATAFRAMELY_MAX_FAILURE_EXAMPLES` if set, else `5`.


## Returns


`dg.AssetChecksDefinition`  
One definition with every check, which Dagster runs in one step. Pass it to `dg.Definitions(asset_checks=[...])`.


## Raises


`InvalidSettingError`  
A setting's argument or environment variable has a value the setting does not allow.

`ReservedColumnError`  
A column name is in the reserved `dy_` namespace.

`InvalidColumnNameError`  
A column name has a character Dagster does not allow in an asset check name.

`CheckNameCollisionError`  
Two rules produce the same asset check name.

`InvalidSeverityError`  
The schema declares a severity this package cannot read.

`ColumnSchemaError`  
In a run, the table's columns or dtypes do not match the schema.


## Examples


``` python
import dagster_dataframely as dd
from dagster_dataframely.data import OrdersSchema

warehouse_checks = dd.build_rule_checks(OrdersSchema, asset="warehouse_orders")
[spec.name for spec in warehouse_checks.check_specs][:4]
```


    ['dy_schema__columns',
     'dy_rule__paid_orders_have_amount',
     'dy_rule__line_numbers_are_dense',
     'dy_rule__primary_key']
