# CASE: check if Belgian VAT number is valid

**URL:** <https://community.silverfin.com/t/case-check-if-belgian-vat-number-is-valid/1328>\
**Category:** Cases\
**Tags:** use\_case\
**Created:** [December 20, 2018, 4:17pm UTC](https://community.silverfin.com/t/case-check-if-belgian-vat-number-is-valid/1328 "2018-12-20T16:17:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [December 20, 2018, 4:17pm UTC](https://community.silverfin.com/t/case-check-if-belgian-vat-number-is-valid/1328/1 "2018-12-20T16:17:23Z")

</div>

If you want to check if a Belgian VAT number is valid or not (check modulo 97), you can see how you can configure just that in below case:

```auto
{% comment %}remove any string values that could be present{% endcomment %}
{% assign vat_nbr = custom.vat.nbr | remove:"BE" | remove:"BE0" | remove:" " | remove:"-" | remove:"." %}
{% comment %}create the vat nbr that can be only 9 numbers long!{% endcomment %}
{% if vat_nbr.size == 10 %}
  {% assign vat_nbr = vat_nbr | slice:1,9 %}
{% elsif vat_nbr.size == 9 %}
  {% assign vat_nbr = vat_nbr %}
{% endif %}
{% comment %}remove last 2 numbers{% endcomment %}
{% assign vat = vat_nbr | slice:0,7 %}
{% comment %}calculate modulo 97{% endcomment %}
{% assign calc_modulo = vat | modulo:97 %}
{% comment %}calculate difference between "97" and var "calc_modulo"{% endcomment %}
{% assign calc_modulo = 97-calc_modulo %}
{% comment %}if the check is 00, then it needs to be seen as "97"; if not, take the real value{% endcomment %}
{% if calc_modulo == 0 %}
  {% assign calc_modulo = 97 %}
{% else %}
  {% assign calc_modulo = calc_modulo %}
{% endif %}
{% comment %}create last 2 numbers of vat nbr{% endcomment %}
{% assign vat_nbr = vat_nbr | slice:-2,2 %}
{% comment %}compare vat_nbr & calc_modulo. If not the same, the VAT number is invalid{% endcomment %}
{% if INT(vat_nbr) != INT(calc_modulo) %}
  {% assign vat_ind = calc_modulo %}
  {% capture vat_warning %}
    {::warningtext as="hover"}
    {% t "Invalid VAT number" %}
    {:/warningtext}
  {% endcapture %}
{% else %}
  {% assign vat_ind = 0 %}  
{% endif %}

{% stripnewlines %}
|-----
{% newline %}
| {% unreconciled vat_ind as:indicator %}
  {% input custom.vat.nbr %}
  {{ vat_warning }}
{% endstripnewlines %}

```

All information is there between comment-tags.
