Custom validators with parameters

How can I add custom validators with parameters in API Tools GUI?

I wrote a custom validator + factory.

I have some setters+getters there.

How can I configure this validator the way it would:

  • show up in the list of available validators in the GUI (I’m adding a factory to validators.factories key in the module.config.php
  • allow the user to choose parameters (eg. maxlen, minlen etc.). Now it shows only one option available: breakchainonfailure

Similar to the StringLength validator:

Options

My factory:

<?php

namespace My\Validator\DoctrineConnected\Factory;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;

class ExistsValidatorFactory implements AbstractFactoryInterface {
    /**
     * Create an object
     *
     * @param  ContainerInterface $container
     * @param  string $requestedName
     * @param  null|array $options
     * @return object
     * @throws ServiceNotFoundException if unable to resolve the service.
     * @throws ServiceNotCreatedException if an exception is raised when
     *     creating a service.
     * @throws ContainerException if any other error occurs
     */
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null) {
        $entityManger = $container->get('doctrine.entitymanger.orm_default');
        return new $requestedName($entityManger);
    }

    public function canCreate(ContainerInterface $container, $requestedName)
    {
        return class_exists($requestedName);
    }
}