PHP code example of coderavine / sparta

1. Go to this page and download the library: Download coderavine/sparta 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/ */

    

coderavine / sparta example snippets



use Sparta\Validators\Date; 
	    
$dateValidator = new Date();  
if(!$dateValidator->isValid('2007-01-01')){
	//Error messages can be simply retrieved using "errors" method
	$errors = $dateValidator->errors();
}


	//We define our rules for the username field as specified above
	$rules = [
		'username' => '



$data = [
	//This could be coming from $_POST, $_GET,etc.,
	'username => 'JohnDoe', 
];


use Sparta\Validation;
    
$validation = new Validation($data,$rules);
if(!$validation->isValid()){
	//Get error messages and manipulate them however you want
	$validation->getErrors();
 }