---
# System prepended metadata

title: Backend validation

---

# Backend validation

* Status: proposed
* Deciders: Piotr Kłósek Michał Masłowski
* Date: 2020-04-15
Technical Story: [https://makeitright.atlassian.net/browse/MVP-9] (https://makeitright.atlassian.net/browse/MVP-9)

## Context and Problem Statement

For now on our validation is done by using IF statement. Developer has to do validation by himself writing validation process instead of using ready solution to validate whole struct coming from FrontEnd. We should use tool that provides struct validation.

## Decision Drivers 

- Easy to implement and cooperate with choosen JSON responses
- Can be modify by own rules of validation
- One generic method for all request

## Considered Options

* [https://github.com/go-playground/validator](https://github.com/go-playground/validator)
* [https://github.com/go-ozzo/ozzo-validation](https://github.com/go-ozzo/ozzo-validation)
* Custom validator

## Decision Outcome

Chosen option: [https://github.com/go-playground/validator](https://github.com/go-playground/validator), once implemented solution can be use in whole system. Choosen option allow to extend validation process by custom validation. Easily validate incoming request by restricted and predefined types.

### Positive Consequences <!-- optional -->

- Used already in custom fields
- Have many already defined validation cases
- Allow to validate nested elements
- Allow to use corss-field validation
- Easily convert for JSON response standard 
- Define validation optionsin golang tags 

## Pros and Cons of the Options <!-- optional -->

### [https://github.com/go-ozzo/ozzo-validation](https://github.com/go-ozzo/ozzo-validation)

- Good, because have many validation cases already defined
- Good, because easy way to convert for JSON reponse standard 

### Custom walidator

- Good, because full custom validation
- Good, because can be convert to any type of response
- Bad, because have no already define validation cases
