Package: laravalidation
LaraValidationOriginal forked repo:https://github.com/walid-mashal/Laravel-ValidationLaraValidationis a python module containing logic for implementing Laravel style Data Validation using python language. This code can be used with html forms to validate their input fields and can also be used with any kind of other data as long as the data is in the form of a python dictionary.For Example we can have some data in the form of a python dictionary as the following:data = { 
    'name':'2222222',   
    'phone':'2',  
    'birthday':'1991/03/04',    
    'email':'info@example.com',    
    'host':'172.30.30.231',  
    'website':'https://www.example.com', 
    'nationality':'afghan',
    'active':'1',  
}that needs to be validated.So we can write Rules to validate the data in the following wayrules = { 
    'name':'required|size:20',   
    'phone':'phone', 
    'birthday':'date|date_format:%Y/%m/%d', 
    'email':'required|email',
    'host':'ip', 
    'website':'website', 
    'nationality':'in:afghan,pakistani,irani',
    'active':'boolean'
}Description:Thenamefield is a required field and only allows a maximum value of 20 characters.ThePhonefield is a telephone number field and a valid phone number should be entered for this field.Thebirthdayfield is a date field and the value entered should be a valid date, the date_format allows you to specify a date format that the field should be filled with.Theemailis also required and a valid email should be entered into that fieldHostmust be a valid ip address e.g. 196.3.3.8Websitemust be a valid website address e.g.http://www.google.comNationalitycan be one of the three provided strings: afghan,pakistani,iraniActivemust be one of the following: 1,0,"1","0","false","true",False,TrueNow we can write the following code to validate thedata:from validation import Validation

validator = Validation()
errors = validator.validate(data,rules)Now theerrorscontain a list of  error messages that is the result of the validation.validate()also takes an optionalcustom_messagesargument which will set user messages to be used for validation, or instead of passing thecustom_messagesargument you can actually set the messages of your own choice using thecutom_error_messages.jsonfile.We can call theis_valid()method to validate the data and will return eitherTrueorFalsefrom validation import Validation

validator = Validation()
isvalid = validator.is_valid(data,rules)

errors = validator.errorsAftervalidate()oris_valid()there will be an instance variable with the nameerrorsset on the object that holds the list of validation error messages.Validation RulesThe following is a list of the validation rules availableafterThe field under validation must be a value after a given date.alphaThe field under validation must be entirely alphabetic characters.alpha_numThe field under validation must be entirely alpha-numeric characters.before:dateThe field under validation must be a value preceding the given date.between:min,maxThe field under validation must have a size between the givenminandmax. Strings and numerics are evaluated in the same fashion as thesizerule.booleanThe field under validation must be able to be cast as aboolean. Accepted input values are true, false, 1, 0, "1" and "0".confirmedThe field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.dateThe field under validation must be a valid date, the default value for the format is%m/%d/%Yif nodate_formatrule is applied.date_format:formatThe field under validation must match the format defined in theformat, the default format is%m/%d/%Y. This rule should be preceeded by thedaterule.different:fieldThe given field must be different than the field under validation.digits:valueThe field under validation must be numeric and must have an exact length ofvalue.emailThe field under validation must be formatted as an e-mail address.integerThe field under validation must have an integer value.ipThe field under validation must be formatted as an IP address.max:valueThe field under validation must be less than or equal to a maximum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.min:valueThe field under validation must have a minimum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.not_in:foo,bar,...The field under validation must not be included in the given list of values.presentThe field under validation must be present in the input data but can be empty.regex:patternThe field under validation must match the given regular expression.requiredThe field under validation must be present in the input data.same:fieldThe given field must match the field under validation.size:valueThe field under validation must have a size matching the givenvalue. For string data, value corresponds to the number of characters. For numeric data,valuecorresponds to a given integer value.websiteThe field under validation must have a valid website url as value. for example:https://www.example.comorwww.example.com