# 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:** 5

<div class="post-metadata">

**Author:** ![josh](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@josh](https://discourse.getdbt.com/u/josh)\
**Post date:** [February 9, 2019, 3:33am UTC](https://discourse.getdbt.com/t/examples-of-custom-schema-tests/181/5 "2019-02-09T03:33:01Z")

</div>

We wanted to be able to test that numbers (float or non-float) were between a certain set of values. So we did this:

```
{% macro test_is_between(model, column_name, bottom_number, top_number) %}

with validation as (

    select
        {{ column_name }} as field_to_test

    from {{ model }}

),

validation_errors as (

    select
        field_to_test

    from validation
    where field_to_test > {{ top_number }} or field_to_test < {{ bottom_number }}

)

select count(*)
from validation_errors

{% endmacro %}

```

And here is an example of a test:

```
  - name: flight_end_long
    tests:
      - is_between: {'bottom_number' : -180, 'top_number' : 180}
```

---

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