Download the PHP package maplephp/validate without Composer
On this page you can find all versions of the php package maplephp/validate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maplephp/validate
More information about maplephp/validate
Files in maplephp/validate
Package validate
Short Description User-friendly input validation library.
License Apache-2.0
Homepage https://wazabii.se
Rated 5.00 based on 1 reviews
Informations about the package validate
MaplePHP - Validation
MaplePHP - Validation is a lightweight and powerful PHP library designed to simplify the validation of various data inputs. Whether you're verifying if a value is a valid email or phone number, ensuring string lengths, or performing more advanced checks like credit card numbers and dates, MaplePHP - Validation offers a comprehensive and intuitive approach. With its wide range of built-in validators and simple syntax, it makes handling complex validation tasks easier, leading to cleaner and more reliable code.
Installation
Install the library via Composer:
Getting Started
You can validate values by instantiating the Validator class. There are two ways to do this:
Validating Nested Data
You can traverse nested arrays or objects and validate specific values using dot notation:
💡 You can also use
validateInData()for more dynamic validations:
Using the Chain validations
The ValidationChain class allows you to chain multiple validations on a single value and check the overall result:
🧠
ValidationChainis useful when you want to collect and evaluate multiple validation rules at once.
Validations
Required field
Check if there is any value (even if it's 0)
Check string length (min, max)
-
Min only:
- Min and Max:
Check if string has an exact length
Check if value equals exactly to or not equals another value
-
Equals: Strict data type validation check if equals to expected value
-
Loosely Equals: Flexible data type validation check if loosely equals to expected value
-
Not equals: Strict data type validation check if not equals to expected value
-
Loosely Not equals: Flexible data type validation check if loosely not equals to expected value
-
More than:
-
Less than:
-
Contains:
-
Starts with:
- Ends with:
Validate if it's a valid email
Validate if it's a valid phone number
Allows numbers and special characters ("-", "+", " ").
Validate Swedish personal number (personnel)
Validate Swedish organization number
Validate credit card number
Validate VAT number
Check if value is a valid float
Check if value is a valid integer
Check if value is a valid number (numeric)
Check if value is positive or negative
-
Positive:
- Negative:
Check if value is a valid version number
Compare version with another version
Validate password (lossy or strict)
-
Lossy password (minimum character set):
- Strict password (requires at least one lowercase, uppercase, digit, and special character):
Validate if value is string and contains only A-Z
-
Both cases:
-
Lowercase only:
- Uppercase only:
Check if it's a valid hex color code
Check if it's a valid date
As default you can validate against a date format like this "Y-m-d"
Custom date validation
Check if it's a valid date and time
Check if it's a valid time
Validate hour and minutes
Validate hour, minutes and seconds
Check if someone is at least a certain age
Check if it's a valid domain name
Check if it's a valid URL (http/https is required)
Check if it's a valid DNS entry
Validate file and directory properties
-
Check if it's a valid file:
-
Check if it's a directory:
-
Check if it's writable:
- Check if it's readable:
Validate ZIP code (with custom length)
Validate if value matches a pattern (regex)
Validate Arrays
Check if is an array
Check if array is empty
Strict data type validation check if value exists in given array
Flexible data type validation check if value exists in given array
Strict data type validation check if key exists in array
Check if all items in array is truthy
Check if truthy item exist in array
Check if array count is equal to length
Check if array count is more than the length
Check if array count is less than the length
Check if value is a valid float
Validate types
Check if value is a valid float
Check if value is a valid float
Check if value is a valid integer
-
Is Boolean:
-
Is Boolean-like value (e.g., "yes", "no", "1", "0"):
-
Array:
-
Object:
-
Resource:
-
Json:
- HTML Document:
HTTP status code validation
Strict data type validation check if value is a valid HTTP status code
Strict data type validation check if value is HTTP 200 OK
Strict data type validation check if value is a 2xx success HTTP code
Strict data type validation check if value is a 4xx client error HTTP code
Strict data type validation check if value is a 5xx server error HTTP code
Validate using multiple methods (one or all must match)
-
Validate if one method passes:
- Validate if all methods pass: