MaplePHP - Validation is a PHP library designed to simplify the process of validating various data inputs. Whether you need to verify if a value is an email or phone number, check for minimum and maximum length constraints, or perform other common validation tasks, MaplePHP - Validation provides a convenient and straightforward solution for handling input validation.
composer require maplephp/validate
You will always initiate instace with the static method _val followed by a value you want to validate.
use MaplePHP\Validate\Inp;
// Validate option 1
$inp = new Inp("Lorem ipsum dolor");
var_dump($inp->length(1, 200)); // true
// Validate option 2
$valid = Inp::value("Lorem ipsum dolor")->length(1, 200);
var_dump($valid); // true
Inp::value("Lorem ipsum dolor")->length(1);
Inp::value("Lorem ipsum dolor")->length(1, 160);
Inp::value("john@gmail.com")->email();
Will allow only numbers and some characters like ("-", "+" and " ").
Inp::value("+46709676040")->phone();
Inp::value("198808213412")->socialNumber();
Inp::value("197511043412")->orgNumber();
Inp::value("1616523623422334")->creditcard();
Inp::value("SE8272267913")->vatNumber();
Inp::value("#000000")->hex();
Inp::value("2022/02/13 14:15")->date("Y/m/d H:i");
// The date argument is the expected date format (will also take time)
Inp::value("2022/02/13 - 2022/02/26")->dateRange("Y/m/d");
// The dateRange argument is the expected date format (will also take time)
Inp::value("1988-05-22")->age("18");
Inp::value("example.com")->domain();
Inp::value("https://example.com/page")->url();
Will check compare result against DNS server and match A, AAAA and MX
Inp::value("example.com")->dns();
Open the file for a lot more validations.