PHP code example of johnbrightn / simple-field-validator
1. Go to this page and download the library: Download johnbrightn/simple-field-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/ */
johnbrightn / simple-field-validator example snippets
$userInputs = $request->getParsedBody(); //object received from user/frontend
//specify ord"=>20];
$value = ValidateFields::validate($
ValidateFields::validate($
use Jbn\Validate\ValidateFields;
$app->post('/register', function (Request $request, Response $response) {
$userInputs = $request->getParsedBody(); //object received from user/frontend
//if there are optional fields, that do not need validation, do not specify them in the ame"=>25, "last_name"=>25, "email"=>60, "username"=>15, "password"=>20];
$value = ValidateFields::validate($l fields
... do other works with the valid fields
$result = $db->registerUser($value);
return $response->withJson($result);
}
});
//if all =>true, "message"=> "No field is set"];
//if a mpty"];
//if a or less"];
//email validation. if email address is present, field should be specified as 'email',
["error"=>true, "message"=> "Invalid email address"];
["error"=>false, $all_fields=>$all_values];
$userInputs = $request->getParsedBody();
//specified me"=>15, "password"=>20];
$customMessage = ["Oops! First Name should not be blank and not more than 25 characters", "Enter your last name and not more than 25 characters", "Enter a username of 15 characters or less", "Password should not exceed 20 characters"];
$value = ValidateFields::validate($
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.