PHP code example of paymobi / yay

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

    

paymobi / yay example snippets




use Yay\Yay;

$input = json_decode(file_get_contents("php://input"));

$schema = [
  "name" => Yay::item()->
  "skillLevel" => Yay::item()->ed()->array()->length(2)->itemsOfType(
    Yay::item()->string()->minLength(10)->maxLength(20)
  ),
  "nickname" => Yay::item()->optional()->string(),
];

$errors = Yay::validate($schema, $input);


if ($errors) {
  echo("request body incorrect");
}

echo("request body correct");
</code>