PHP code example of linmad / structure-type-validation

1. Go to this page and download the library: Download linmad/structure-type-validation 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/ */

    

linmad / structure-type-validation example snippets


$paymentReq = '{
    "amount": 10500,
    "ccy": "EUR",
    "account_id": 42,
    "order_description": "facere repellat provident occaecati excepturi optio reprehenderit"
}';

$payementReqMap = [
    'amount' => 'integer',
    'ccy' => 'string',
    'account_id' => 'integer'
];

// Create instance
$analyzer = new Analyzer();

// Check if structure same as expected in map
$isValid = $analyzer->isValidStructure($paymentReq, $payementReqMap); // return bool, valid or not as expected

if ($isValid) {
    // Make some magic
    $this->paymentProvider->takeRequest($paymentReq);
}
// Or use other magic