PHP code example of polderknowledge / entityservice-zend-validator

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

    

polderknowledge / entityservice-zend-validator example snippets


namespace MyApp\InputFilter;

use PolderKnowledge\EntityService\Validator\EntityExists;
use Zend\InputFilter\InputFilter;
use PonyApp\Entity\Pony;

class PonyEditInputFilter extends InputFilter
{
    /**
     * Initializes the input filter.
     */
    public function init()
    {
        $this->add([
            'name' => 'ponyId',
            'validators' => [
                [
                    'name' => EntityExists::class, // or EntityNotExists
                    'options' => [
                        'entity' => Pony::class,
                        'field' => 'name', // defaults to id 
                    ],
                ],
            ],
        ]);
    }
}