Skip to main content

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-DD and YYYY/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 both YYYY-MM-DD and YYYY/MM/DD formats.
  • 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


Download files

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

Source Distribution

simon_datavalidator-0.11.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

simon_datavalidator-0.11-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

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

Hashes for simon_datavalidator-0.11.tar.gz
Algorithm Hash digest
SHA256 ffbb6c18ebda3c64e778120b403613bd1a853d3780af02f665e58d4e6c581b06
MD5 60dc3371b6e9d91c36b654e49c03d513
BLAKE2b-256 9983c31893234b46606f51c159eda9b77199eb5075f0e5b5b688f4962b73a49a

See more details on using hashes here.

File details

Details for the file simon_datavalidator-0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for simon_datavalidator-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 ad81d5b353a0b0ed8f5b743e8b5d09c3ac561462e5b16cf1ee13131601ba7fa7
MD5 b7aa50fcaa0c35ab9f4dc4e494997bd2
BLAKE2b-256 483874fb3526b16310fd6b5234e473bd32724251332e8643b13385b677be9f3f

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