Skip to main content

onelinevalidation It is a simple library in the Python language that performs validate in an easy and simple way

Project description

onelinevalidation

onelinevalidation It is a simple library in the Python language that performs validate in an easy and simple way

Installation

  • From PyPi
python pip install onelinevalidation

Examples

In default sanitize = True
in validate_form
and custom_validate
This is to prevent a Cross-site Scripting vulnerability
For more https://owasp.org/www-community/attacks/xss/


from onelinevalidation import validate_form


userData = {"username": "amr123", "email": "amr.@aol.com", "password": "123Ab#"}
print(validate_form(userData))
-------------------------
{'error': {'username': 'Invalid username should be like this abc_123 or abc. abc', 'email': 'This email address is not valid', 'password': 'The password length must be at least 8 uppercase, lowercase letters, numbers, symbols like @aA123#*'}
}

------------------------
userData = {"username": "amr_123", "email": "amr@aol.com", "password": "123---Ab#"}
print(validate_form(userData))
------------------------
{'good': {'username': 'amr_123', 'email': 'amr@aol.com', 'password': '123---Ab#'}}



## If you want more control use custom_validate 

from onelinevalidation import custom_validate


pattrens = [
	"[a-zA-Z]+[_.]+[a-zA-Z0-9]+", 
	"[a-zA-Z0-9_-]+[@](aol|gmail|yahoo|outlook)+(.com)+",
	"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$"
]


messages = [
	"Invalid username should be like this abc_123 or abc. abc",
	"This email address is not valid",
	"The password length must be at least 8 uppercase, lowercase letters, numbers, symbols like @aA123#*"
]


print(custom_validate(userData, pattrens, messages))
--------------
{'good': {'username': 'amr_123', 'email': 'amr@aol.com', 'password': '123---Ab#'}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onelinevalidation-0.4.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file onelinevalidation-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for onelinevalidation-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cda68d4dd6a15ff49a3159d1aded61a4c1e2213cd77902c2fb58fe02115c601
MD5 a49df8c684c9c7f7abd0d99f0c54ad44
BLAKE2b-256 ad15533df8fb94ded0d0bd85d7c23faefbc0af2e809f8753ccfe5aa81272f0d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page