1. Go to this page and download the library: Download dashifen/validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dashifen / validator example snippets
class Validator extends AbstractValidator {
protected function getValidationMethod(string $field): string {
// to convert a kebab-case $field to a function name, we want to
// convert it to StudlyCaps. so, first, we convert from kebab-case to
// camelCase and then we ucfirst() the camelCase string to make it
// studly. finally, we add the word "validate." Thus, a start-date
// field becomes startDate, then StartDate, and finally we return
// transformStartDate.
$camelCase = preg_replace_callback("/-([a-z])/", function (array $matches): string {
return strtoupper($matches[1]);
}, $field);
return "validate" . ucfirst($camelCase);
}
private function validateStartDate(string $date): bool {
// what we want to do is make sure that our date appears valid.
// we're less concerned with format (a transform can standardize
// that). here, we just want to know that what we have might be
// a date which is a good job for strtotime()!
return strtotime($date) !== false;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.