multiform-validator


Namemultiform-validator JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryMultilingual library made for validation, various form fields, such as: email, cpf, cnpj, credit card, and much more.
upload_time2024-07-10 18:50:57
maintainerNone
docs_urlNone
authorGabriel Logan
requires_python>=3.1
licenseNone
keywords validator multiform validação email-validator image multiform-validator python security safe pentest security-tools validator validate cpf cnpj email validator password email isemail
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Multiform-validator

[![PyPI version](https://badge.fury.io/py/multiform-validator.svg)](https://badge.fury.io/py/multiform-validator)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI downloads](https://img.shields.io/pypi/dm/multiform-validator.svg?style=flat-square)](https://pypistats.org/packages/multiform-validator)

This package provides Python functions to validate various forms fields.

Documentation: https://multiform-validator.vercel.app/documentation/py

Feel free to find bugs and report them to me. Your feedback is highly appreciated. Hugs from Gabriel Logan!

If you want to help me, you can buy me a coffee (:

<p align="center">
	<a href="https://www.buymeacoffee.com/gabriellogan" target="_blank">
		<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 50px !important;width: 180px !important;" >
	</a>
</p>

### Installation

```bash
pip install multiform-validator
```

# Data Validator

This package contains various modules for validating different types of data. Below are the available validation modules:

# Avaliable for while

- **cnpjValidator**: CNPJ validation.
- **cpfValidator**: CPF validation.
- **getOnlyEmail**: Extracts only the email or emails address from a string.
- **identifyFlagCard**: Identifies the flag of a credit card.
- **isCreditCardValid**: Credit card validation.
- **isEmail**: Email address validation format.
- **passwordStrengthTester**: Password strength test.
- **validateBRPhoneNumber**: Brazilian phone number validation.
- **isValidImage**: Image validation.

## Usage

Here is an example of how to use the functions in this package:

```python
from multiform_validator import (
    cnpjIsValid,
    cpfIsValid,
    getOnlyEmail,
    identifyFlagCard,
    isCreditCardValid,
    isEmail,
    passwordStrengthTester,
    validateBRPhoneNumber,
    isValidImage
)
```

### Usage Example

```python

print("Is email", isEmail("foo@bar.com")) # True
print("Get only email", getOnlyEmail("awdawd wadawd wda awd jhony@gmail.com awdawdawd")) # jhony@gmail.com
print("Password strength", passwordStrengthTester("aA1!asd@qd2asd")) # Strong
print("Is CPF valid", cpfIsValid("123.456.789-02")['isValid']) # False
print("Is CNPJ valid", cnpjIsValid("12.345.678/0001-09")) # { 'isValid': False, 'errorMsg': 'CNPJ is not valid' }
print("Is credit card valid", isCreditCardValid("5117 2161 1334 8362")) # True
print("Identify flag card", identifyFlagCard("5117 2161 1334 8362")) # Mastercard
print("Validate BR phone number", validateBRPhoneNumber("(11) 91234-5678")) # { 'isValid': True, 'errorMsg': None }

```

### isValidImage Usage Example

```python
import os
from pathlib import Path

from multiform_validator import isValidImage

# Resolve the file path
file_path = Path.cwd() / 'static' / 'uploads'
retrieved_file = file_path / filename

# Read the first 4 bytes of the file
with open(retrieved_file, 'rb') as f:
    file_buffer = f.read(4)

print(isValidImage(file_buffer)) # True or False
```

## Functions signature

All params with default values are optional.

```python

def isEmail(email: str) -> bool:
    pass

def getOnlyEmail(text: str, multiple=False, clean_domain=False, repeat_email=False) -> str:
    pass

def passwordStrengthTester(password: str) -> str:
    pass

defaultErrorMsgCPF = [
  'CPF invalid',
  'CPF must have 11 numerical digits',
  'CPF is not valid',
  'Unknown error',
]
def cpfIsValid(cpf: str, errorMsg=defaultErrorMsgCPF) -> Dict[str, Union[bool, str, None]]:
    pass

default_error_msgCNPJ = [
   'CNPJ invalid', 
   'CNPJ must have 14 numerical digits', 
   'CNPJ is not valid', 
   'Unknown error'
]
def cnpjIsValid(cnpj: str, errorMsg=default_error_msgCNPJ) -> Dict[str, Union[bool, str, None]]:
    pass

def isCreditCardValid(cardNumber: str) -> bool:
    pass

def identifyFlagCard(cardNumber: str) -> str:
    pass

default_error_msg = ['Invalid value passed', 'Invalid phone number', 'Unknown error']
def validateBRPhoneNumber(phoneNumber: str, errorMsg=default_error_msg) -> Dict[str, Union[bool, str, None]]:
    pass

def isValidImage(file_buffer: bytes) -> bool:
    pass

```

## Looking for contributions. 

## Available Validation Modules !!! STILL NOT AVALIABLE !!!

- **isAscii**: Checks if the string contains only ASCII characters.
- **isBase64**: Checks if the string is a valid Base64 encoding.
- **isCEP**: CEP validation (Brazilian postal code).
- **isDate**: Date format validation.
- **isDecimal**: Checks if the number is a decimal.
- **isEmpty**: Checks if the string is empty.
- **isMACAddress**: MAC address validation.
- **isMD5**: Checks if the string is a valid MD5 hash.
- **validatePassportNumber**: Passport number validation.
- **isPort**: Port number validation.
- **isPostalCode**: Postal code validation.
- **isTime**: Time format validation.
- **validateEmail**: Email address full validation.
- **validatePassword**: Password validation.
- **validatePhoneNumber**: Phone number validation.
- **validateUsername**: Username validation.
- **validateUSPhoneNumber**: US phone number validation.
- **isNumber**: Checks if the value is a number.
- **validateName**: Name validation.
- **validateSurname**: Surname validation.
- **validateTextarea**: Textarea validation.

### For better information, read the documentation

Feel free to explore the various functions and experiment with different inputs to understand their behavior. If you encounter any issues or have suggestions, don't hesitate to reach out to me. Your feedback is valuable and helps improve the package. Happy coding!

# By - Gabriel Logan

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "multiform-validator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.1",
    "maintainer_email": null,
    "keywords": "validator, multiform, valida\u00e7\u00e3o, email-validator, image, multiform-validator, python, security, safe, pentest, security-tools, Validator, validate, cpf, cnpj, email validator, password, email, isEmail",
    "author": "Gabriel Logan",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/05/51/3dfc02c78ce09efe9298de79b9922b65d0cb75d528141256d9564a985367/multiform_validator-1.0.2.tar.gz",
    "platform": null,
    "description": "# Multiform-validator\n\n[![PyPI version](https://badge.fury.io/py/multiform-validator.svg)](https://badge.fury.io/py/multiform-validator)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PyPI downloads](https://img.shields.io/pypi/dm/multiform-validator.svg?style=flat-square)](https://pypistats.org/packages/multiform-validator)\n\nThis package provides Python functions to validate various forms fields.\n\nDocumentation: https://multiform-validator.vercel.app/documentation/py\n\nFeel free to find bugs and report them to me. Your feedback is highly appreciated. Hugs from Gabriel Logan!\n\nIf you want to help me, you can buy me a coffee (:\n\n<p align=\"center\">\n\t<a href=\"https://www.buymeacoffee.com/gabriellogan\" target=\"_blank\">\n\t\t<img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 50px !important;width: 180px !important;\" >\n\t</a>\n</p>\n\n### Installation\n\n```bash\npip install multiform-validator\n```\n\n# Data Validator\n\nThis package contains various modules for validating different types of data. Below are the available validation modules:\n\n# Avaliable for while\n\n- **cnpjValidator**: CNPJ validation.\n- **cpfValidator**: CPF validation.\n- **getOnlyEmail**: Extracts only the email or emails address from a string.\n- **identifyFlagCard**: Identifies the flag of a credit card.\n- **isCreditCardValid**: Credit card validation.\n- **isEmail**: Email address validation format.\n- **passwordStrengthTester**: Password strength test.\n- **validateBRPhoneNumber**: Brazilian phone number validation.\n- **isValidImage**: Image validation.\n\n## Usage\n\nHere is an example of how to use the functions in this package:\n\n```python\nfrom multiform_validator import (\n    cnpjIsValid,\n    cpfIsValid,\n    getOnlyEmail,\n    identifyFlagCard,\n    isCreditCardValid,\n    isEmail,\n    passwordStrengthTester,\n    validateBRPhoneNumber,\n    isValidImage\n)\n```\n\n### Usage Example\n\n```python\n\nprint(\"Is email\", isEmail(\"foo@bar.com\")) # True\nprint(\"Get only email\", getOnlyEmail(\"awdawd wadawd wda awd jhony@gmail.com awdawdawd\")) # jhony@gmail.com\nprint(\"Password strength\", passwordStrengthTester(\"aA1!asd@qd2asd\")) # Strong\nprint(\"Is CPF valid\", cpfIsValid(\"123.456.789-02\")['isValid']) # False\nprint(\"Is CNPJ valid\", cnpjIsValid(\"12.345.678/0001-09\")) # { 'isValid': False, 'errorMsg': 'CNPJ is not valid' }\nprint(\"Is credit card valid\", isCreditCardValid(\"5117 2161 1334 8362\")) # True\nprint(\"Identify flag card\", identifyFlagCard(\"5117 2161 1334 8362\")) # Mastercard\nprint(\"Validate BR phone number\", validateBRPhoneNumber(\"(11) 91234-5678\")) # { 'isValid': True, 'errorMsg': None }\n\n```\n\n### isValidImage Usage Example\n\n```python\nimport os\nfrom pathlib import Path\n\nfrom multiform_validator import isValidImage\n\n# Resolve the file path\nfile_path = Path.cwd() / 'static' / 'uploads'\nretrieved_file = file_path / filename\n\n# Read the first 4 bytes of the file\nwith open(retrieved_file, 'rb') as f:\n    file_buffer = f.read(4)\n\nprint(isValidImage(file_buffer)) # True or False\n```\n\n## Functions signature\n\nAll params with default values are optional.\n\n```python\n\ndef isEmail(email: str) -> bool:\n    pass\n\ndef getOnlyEmail(text: str, multiple=False, clean_domain=False, repeat_email=False) -> str:\n    pass\n\ndef passwordStrengthTester(password: str) -> str:\n    pass\n\ndefaultErrorMsgCPF = [\n  'CPF invalid',\n  'CPF must have 11 numerical digits',\n  'CPF is not valid',\n  'Unknown error',\n]\ndef cpfIsValid(cpf: str, errorMsg=defaultErrorMsgCPF) -> Dict[str, Union[bool, str, None]]:\n    pass\n\ndefault_error_msgCNPJ = [\n   'CNPJ invalid', \n   'CNPJ must have 14 numerical digits', \n   'CNPJ is not valid', \n   'Unknown error'\n]\ndef cnpjIsValid(cnpj: str, errorMsg=default_error_msgCNPJ) -> Dict[str, Union[bool, str, None]]:\n    pass\n\ndef isCreditCardValid(cardNumber: str) -> bool:\n    pass\n\ndef identifyFlagCard(cardNumber: str) -> str:\n    pass\n\ndefault_error_msg = ['Invalid value passed', 'Invalid phone number', 'Unknown error']\ndef validateBRPhoneNumber(phoneNumber: str, errorMsg=default_error_msg) -> Dict[str, Union[bool, str, None]]:\n    pass\n\ndef isValidImage(file_buffer: bytes) -> bool:\n    pass\n\n```\n\n## Looking for contributions. \n\n## Available Validation Modules !!! STILL NOT AVALIABLE !!!\n\n- **isAscii**: Checks if the string contains only ASCII characters.\n- **isBase64**: Checks if the string is a valid Base64 encoding.\n- **isCEP**: CEP validation (Brazilian postal code).\n- **isDate**: Date format validation.\n- **isDecimal**: Checks if the number is a decimal.\n- **isEmpty**: Checks if the string is empty.\n- **isMACAddress**: MAC address validation.\n- **isMD5**: Checks if the string is a valid MD5 hash.\n- **validatePassportNumber**: Passport number validation.\n- **isPort**: Port number validation.\n- **isPostalCode**: Postal code validation.\n- **isTime**: Time format validation.\n- **validateEmail**: Email address full validation.\n- **validatePassword**: Password validation.\n- **validatePhoneNumber**: Phone number validation.\n- **validateUsername**: Username validation.\n- **validateUSPhoneNumber**: US phone number validation.\n- **isNumber**: Checks if the value is a number.\n- **validateName**: Name validation.\n- **validateSurname**: Surname validation.\n- **validateTextarea**: Textarea validation.\n\n### For better information, read the documentation\n\nFeel free to explore the various functions and experiment with different inputs to understand their behavior. If you encounter any issues or have suggestions, don't hesitate to reach out to me. Your feedback is valuable and helps improve the package. Happy coding!\n\n# By - Gabriel Logan\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Multilingual library made for validation, various form fields, such as: email, cpf, cnpj, credit card, and much more.",
    "version": "1.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/gabriel-logan/multiform-validator/tree/main/packages/python",
        "Homepage": "https://multiform-validator.vercel.app/documentation"
    },
    "split_keywords": [
        "validator",
        " multiform",
        " valida\u00e7\u00e3o",
        " email-validator",
        " image",
        " multiform-validator",
        " python",
        " security",
        " safe",
        " pentest",
        " security-tools",
        " validator",
        " validate",
        " cpf",
        " cnpj",
        " email validator",
        " password",
        " email",
        " isemail"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e194df443a10ca90865ceff9d6d5778424017ae46259a6043c025b0a838e6b19",
                "md5": "48f330cf41d1e6a596a7bdb68897299e",
                "sha256": "825d24c56bb69dc142e2e60d65a121d4c7c47bd7a6087858728846ecb0a6bbe6"
            },
            "downloads": -1,
            "filename": "multiform_validator-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48f330cf41d1e6a596a7bdb68897299e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.1",
            "size": 11300,
            "upload_time": "2024-07-10T18:50:56",
            "upload_time_iso_8601": "2024-07-10T18:50:56.173366Z",
            "url": "https://files.pythonhosted.org/packages/e1/94/df443a10ca90865ceff9d6d5778424017ae46259a6043c025b0a838e6b19/multiform_validator-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05513dfc02c78ce09efe9298de79b9922b65d0cb75d528141256d9564a985367",
                "md5": "1ce2a148e88a71f0f841395ee76beec2",
                "sha256": "cfa49c2090c93d9ef3829f259b38f532eabc98a849c0e87f7f26bf0247d10940"
            },
            "downloads": -1,
            "filename": "multiform_validator-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1ce2a148e88a71f0f841395ee76beec2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.1",
            "size": 11225,
            "upload_time": "2024-07-10T18:50:57",
            "upload_time_iso_8601": "2024-07-10T18:50:57.572941Z",
            "url": "https://files.pythonhosted.org/packages/05/51/3dfc02c78ce09efe9298de79b9922b65d0cb75d528141256d9564a985367/multiform_validator-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-10 18:50:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gabriel-logan",
    "github_project": "multiform-validator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "multiform-validator"
}
        
Elapsed time: 4.08757s