Python3 Validation in another way
Project description
SmileValidation
Python3 Validation in another way
I hurt enough for validating those form's elements. Time to bring a new technique type. It's gonna solve like this way:
Validator class
That's core class of the tool. It contains the validation element after added element into collect and it will valid the element by called isValid()
from Validator import Validator
# validition instance
v = Validator()
## float validation
# add element with
v.addElement(
elementName= 'computer-quatity'
, elementValue= 2
, rule= TypeSchema().getFloat(
require= True
, max= 5
, min= 1
, negative= False
)
)
## start validating
# true if every element is correct
if v.isValid():
print(f'Everything is fine')
else:
print(f'Error: {v.getError()}')
Rule class
It is the collection of what we wanna validate to those element objects. What Rule will help validation class is, make it all reusable.
Example:
# sample
class Rule:
def getQualityOne(self) -> dict:
"""
:return:
"""
return TypeSchema().getFloat(
require= True
, max= 5
, min= 1
, negative= False
)
getQualityOne will replace previous one.
# sample with two elements
from Validator import Validator
# validition instance
v = Validator()
## float validation
# add element with
v.addElement(
elementName= 'computer-quatity'
, elementValue= 2
, rule= Rule.getQualityOne()
)
v.addElement(
elementName= 'tv-quatity'
, elementValue= 4
, rule= Rule.getQualityOne()
)
## start validating
# true if every element is correct
if v.isValid():
print(f'Everything is fine')
else:
print(f'Error: {v.getError()}')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
SmileValidation-1.1.0.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for SmileValidation-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3893e14fb5126787acb0a7098d6e9dd5024c06ba56dcaccca47de8dcbc081cb6 |
|
MD5 | ab232795defc7192bd2f3e684dfb8a70 |
|
BLAKE2b-256 | 1a30e5cc88e5e6fe7337f010c95c6d06a74246a1fb73568b5040ba21744ab5a1 |