ap-lib / validator-us
dev-main
2025-03-05 22:55 UTC
Requires
- php: ^8.3
- ext-mbstring: *
- ap-lib/validator: dev-main
Requires (Dev)
- phpunit/phpunit: 10.5.*
This package is auto-updated.
Last update: 2025-03-05 22:55:15 UTC
README
A set of US-specific input validators, ensuring proper formatting and sanitization.
Installation
composer require ap-lib/validator-us
Modules
- CitySanitizes - Ensures valid US city names, removing invalid characters and normalizing formatting.
- NameSanitizes - Sanitizes personal names, ensuring proper structure while preserving necessary characters.
Requirements
- PHP 8.3 or higher
Getting started
Sanitizing a City Name
use AP\Validator\US\CitySanitizes; $city = " New!! York--"; $validator = new CitySanitizes(); if ($validator->validateString($city) === true) { echo "Sanitized City: " . $city; // Output: "New York" } else { echo "Invalid city name!"; }
Sanitizing a Personal Name
use AP\Validator\US\NameSanitizes; $name = " O``Brien--"; $validator = new NameSanitizes(); if ($validator->validateString($name) === true) { echo "Sanitized Name: " . $name; // Output: "O'Brien" } else { echo "Invalid name!"; }