parameters:
    env(ALLOWED_NETWORK_WHITELIST): ''

services:
    akeneo_connectivity.connection.validators.connection.code_must_be_unique:
        class: Akeneo\Connectivity\Connection\Application\Settings\Validation\Connection\CodeMustBeUniqueValidator
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.connection'
        tags:
            - { name: validator.constraint_validator, alias: connection_code_must_be_unique }

    akeneo_connectivity.connection.validators.connection.image_must_exist:
        class: Akeneo\Connectivity\Connection\Application\Settings\Validation\Connection\ImageMustExistValidator
        arguments:
            - '@akeneo_connectivity.connection.service.file_info.does_image_exist'
        tags:
            - { name: validator.constraint_validator, alias: connection_image_must_exist }

    akeneo_connectivity.connection.validators.webhook.connection_must_exist:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Validation\ConnectionMustExistValidator
        arguments:
            - '@akeneo_connectivity.connection.persistence.repository.connection'
        tags:
            - { name: validator.constraint_validator, alias: connection_must_exist }

    akeneo_connectivity.connection.validators.webhook.event_subscriptions_limit:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Validation\EventSubscriptionsLimitValidator
        arguments:
            - '@akeneo_connectivity.connection.persistence.query.select_active_webhooks'
            - '%webhook_active_event_subscriptions_limit%'
        tags:
            - { name: validator.constraint_validator }

    akeneo_connectivity.connection.validators.webhook.external_url:
        class: Akeneo\Connectivity\Connection\Application\Webhook\Validation\ExternalUrlValidator
        arguments:
            - '@akeneo_connectivity.connection.dns_lookup'
            - '@akeneo_connectivity.connection.ip_matcher'
            - '%env(string:ALLOWED_NETWORK_WHITELIST)%'
        tags:
            - { name: validator.constraint_validator }

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Validation\ClientIdMustBeValidValidator:
        arguments:
            - '@fos_oauth_server.client_manager.default'
        tags:
            - { name: validator.constraint_validator }

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Validation\AuthorizationCodeMustBeValidValidator:
        arguments:
            - '@fos_oauth_server.storage.default'
        tags:
            - { name: validator.constraint_validator }

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Validation\ClientIdMustHaveOngoingAuthorizationValidator:
        arguments:
            - '@Akeneo\Connectivity\Connection\Infrastructure\Apps\Session\AppAuthorizationSession'
        tags:
            - { name: validator.constraint_validator }

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Validation\CodeChallengeMustBeValidValidator:
        arguments:
            - '@akeneo_connectivity.connection.marketplace.web_marketplace_api'
            - '@akeneo_connectivity.connection.marketplace_fake_apps.feature'
        tags:
            - { name: validator.constraint_validator }

    Akeneo\Connectivity\Connection\Infrastructure\Apps\Validation\UserIdMustBeValidValidator:
        arguments:
            - '@pim_user.repository.user'
        tags:
            - { name: validator.constraint_validator }
