# Examples of custom schema tests

**URL:** <https://discourse.getdbt.com/t/examples-of-custom-schema-tests/181>\
**Category:** Show and Tell\
**Tags:** testing\
**Created:** [November 29, 2018, 1:50pm UTC](https://discourse.getdbt.com/t/examples-of-custom-schema-tests/181 "2018-11-29T13:50:28Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![claire](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/claire/32/522_2.png) [@claire](https://discourse.getdbt.com/u/claire)\
**Post date:** [November 30, 2018, 4:27pm UTC](https://discourse.getdbt.com/t/examples-of-custom-schema-tests/181/4 "2018-11-30T16:27:11Z")

</div>

We put all of the custom schema tests we find useful in [dbt-utils](https://github.com/fishtown-analytics/dbt-utils#schema-tests).

One pattern which is super simple but really useful to implement is the use of the `expression_is_true` test, so you can define your own logic without having to write the sql for a test. I used this _a lot_ in financial models when I had to validate that subtotal columns were equal to a total, that financial values were positive, etc. etc., so my schema.yml would look like:

```auto
version: 2

models:
  - name: payments
    tests:
      - dbt_utils.expression_is_true:
          expression: "inbound_amount = payout_amount + refund_amount"
      - dbt_utils.expression_is_true:
          expression: "inbound_amount = inbound_cash_amount + inbound_credit_amount"

```

---

_[View the full topic](https://discourse.getdbt.com/t/examples-of-custom-schema-tests/181)._
