Mastering Data Validation with Sanatio
Sanatio (derived from the Latin word for “Validation”) is a powerful Python package designed to validate various data types. Whether you’re handling user input, API responses, or database entries, Sanatio ensures that your data adheres to specific rules and formats. In this article, we’ll explore how to use the Sanatio effectively.
Installation
First, let’s make sure you have Sanatio installed. You can do this via pip:
pip install sanatio
Key Features
2. Built-in Validators:
3. Custom Validators:
领英推荐
Password Validation
Let’s validate a password, and check if the given password is valid or not
from sanatio import Sanatio
val = Sanatio()
>>> val.isStrongPassword('123456')
False
>>> val.isStrongPassword('123456789@Abc',
min_length=6,
lowercase=True,
uppercase=True,
special_chars)
True
String Validation
check if the two strings are the same.
val.equals("abc", "abc")
True
>>> val.equals("abc", "ABC")
False
>>> val.equals("abc", "ABC", ignoreCase=True)
True
The full documentation is available here. If you love contributing to open source, here is the source code.