PHP code example of henriqueramos / laravel_json_schema_validator

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

    

henriqueramos / laravel_json_schema_validator example snippets


$schemaJson = <<<'JSON'
{
    "type": "object",
    "properties": {
        "uuid": {
            "type": "integer"
        },
        "userId": {
            "type": "integer"
        },
        "items": {
            "type": "array",
            "minimum": 1,
            "items": {
                "$ref": "#/definitions/items"
            }
        }
    },
    "string",
                    "format": "date-time"
                }
            },
            "

 declare(strict_types = 1);

namespace RamosHenrique\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ValidatingPayloadRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'jsonData' => [
                'bail',
                '