bespoyasov / rule-based-data-validation

Declarative data validation made with rule-based approach and functional programming.

Home Page:https://bespoyasov.ru/showcase/declarative-validation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Declarative validation in rule-based approach and functional programming

Sample frontend app with HTML-form data validation made using a rule-based approach, written in TypeScript and (almost pure) functional programming paradigm.

About Project

Client data validation is complicated. It requires different types of logic to work together, and sometimes difficult to distinguish those types properly. This can result in a messy code.

The rule-based approach helps to separate domain, UI, and infrastructure logic. It makes the validation rules independent from the other code and reusable in different projects.

Read more about this approach in my posts:

App Example

For this post, I created a sample app—Mars colonizer application form.

This form contains fields with different data types (name, date, email, phone, password), different sets of rules and relationships, and even interdependent rules.

Check out the form yourself to see how it's working!

Source Code

Although the main idea is explained in the posts, I left some comments in the source code. Check out the validation rules and the validation infrastructure code to feel the idea behind the rule-based validation.

About

Declarative data validation made with rule-based approach and functional programming.

https://bespoyasov.ru/showcase/declarative-validation/


Languages

Language:TypeScript 66.7%Language:HTML 21.1%Language:CSS 11.9%Language:JavaScript 0.4%