# metricool/2.1.1/app/Support/Validation/Rules/InRule.php

Metricool – Social media and site statistics, version 2.1.1. 25 lines.

- Page: https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Support/Validation/Rules/InRule.php
- Raw: https://pluginprobe.com/plugins/metricool/2.1.1/raw/app/Support/Validation/Rules/InRule.php
- Modified: 2026-08-20T14:08:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Support/Validation/Rules/InRule.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Metricool\Support\Validation\Rules;

class InRule extends AbstractRule
{
    /**
     * Checks if the field value is one of the given parameters,
     * e.g. "in:countries,referers".
     * @inheritDoc
     */
    public function validate(string $field, $value, array $data): void
    {
        if (!in_array((string) $value, $this->parameters, true)) {
            $this->fail(sprintf(
                /* translators: %s is the field name */
                __('%s is invalid.', 'metricool'),
                $field
            ));
        }
    }
}

```
