PHP code example of storinka / invoke-toolkit-validators

1. Go to this page and download the library: Download storinka/invoke-toolkit-validators 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/ */

    

storinka / invoke-toolkit-validators example snippets


// ensures that array contains only strings
#[ArrayOf("string")]

// ensures that array contains only integers
#[ArrayOf("int")]

// ensures that array contains only items with type SomeData
#[ArrayOf(SomeData::class)]

// ensures that array contains only items with type string or int
#[ArrayOf(["string", "int"])]

// ensures that array contains only items with type string or int or SomeData
#[ArrayOf(["string", "int", SomeData::class])]

// ensures that string length is min 3 and max 16
#[Length(3, 16)]

// ensures that string length is min 3
#[Length(3)]

// ensures that string length is max 16
#[Length(max: 16)]