A simple data validation package
Project description
data-validator-simon-dickson
simon-datavalidator is a Python package that uses Object-Oriented Programming (OOP) to validate various data types, including emails, phone numbers, dates, and URLs, using regular expressions. It also includes comprehensive unit tests to ensure accuracy and reliability.
Features
- Validate email addresses with robust pattern matching.
- Validate phone numbers supporting international formats.
- Validate dates in formats
YYYY-MM-DDandYYYY/MM/DD. - Validate URLs for both HTTP and FTP protocols.
- Comprehensive unit testing with
pytest.
Project Structure
File Breakdown
validator.py
Defines the DataValidator class with the following methods:
validate_email(): Validates email addresses using a regular expression.validate_phone(): Validates phone numbers with support for international formats.validate_date(): Validates date strings in bothYYYY-MM-DDandYYYY/MM/DDformats.validate_url(): Validates URLs supporting both HTTP and FTP protocols.
test_validator.py
Contains unit tests for each validation method using pytest. The tests cover:
- Valid and invalid email addresses.
- Valid and invalid phone numbers.
- Valid and invalid date formats.
- Valid and invalid URLs.
setup.py
Handles the package setup and metadata, including author information and version.
Prerequisites
Ensure you have Python 3.7 or later installed.
Install Dependencies
No external libraries are required, as the project only uses Python’s built-in modules.
To install pytest for testing, run:
pip install pytest
Cloning the Project
To get started, clone the repository:
git clone https://github.com/Data-Epic/data-validator-simon-dickson.git
Running Tests with Pytest
This project includes unit tests to validate its functionality. To run the tests, execute:
pytest -v
Installation
To install the package locally, run:
pip install simon-datavalidator
Instructions for use
Step 1: Creating A Virtual Environment
To create and activate a virtual environment, follow these steps: On Windows:
python -m venv simon-env
simon-env\Scripts\activate
On macOS/Linux:
python3 -m venv simon-env
source simon-env/bin/activate
Step 2: Installing the Package
After creating and activating the virtual environment, install the package as follows:
pip install simon-datavalidator
Step 3: Importing and Using the Package in Your Project
Create a Python file (e.g., main.py) and import the package as follows:
from datavalidator import DataValidator
# Example usage with verbose mode enabled
validator = DataValidator(verbose=True)
# Email validation
validator.data = "user@example.com"
print(validator.validate_email())
# Phone validation
validator.data = "+1234567890"
print(validator.validate_phone())
# Date validation
validator.data = "2024-02-29"
print(validator.validate_date())
# URL validation
validator.data = "https://example.com"
print(validator.validate_url())
Step 4: Running the Script
python main.py
Author
Name: Simon Dickson Email: simonoche987@gmail.com
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simon_datavalidator-0.11.tar.gz.
File metadata
- Download URL: simon_datavalidator-0.11.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffbb6c18ebda3c64e778120b403613bd1a853d3780af02f665e58d4e6c581b06
|
|
| MD5 |
60dc3371b6e9d91c36b654e49c03d513
|
|
| BLAKE2b-256 |
9983c31893234b46606f51c159eda9b77199eb5075f0e5b5b688f4962b73a49a
|
File details
Details for the file simon_datavalidator-0.11-py3-none-any.whl.
File metadata
- Download URL: simon_datavalidator-0.11-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad81d5b353a0b0ed8f5b743e8b5d09c3ac561462e5b16cf1ee13131601ba7fa7
|
|
| MD5 |
b7aa50fcaa0c35ab9f4dc4e494997bd2
|
|
| BLAKE2b-256 |
483874fb3526b16310fd6b5234e473bd32724251332e8643b13385b677be9f3f
|