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

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

- Page: https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Support/Validation/Rules/RequiredRule.php
- Raw: https://pluginprobe.com/plugins/metricool/2.1.1/raw/app/Support/Validation/Rules/RequiredRule.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/RequiredRule.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Metricool\Support\Validation\Rules;

use Metricool\Support\Validation\Validator;

class RequiredRule extends AbstractRule
{
    /**
     * Checks if the field is present and not empty.
     * @inheritDoc
     */
    public function validate(string $field, $value, array $data): void
    {
        if (Validator::isEmptyValue($value)) {
            $this->fail(sprintf(
                /* translators: %s is the field name */
                __('%s is required.', 'metricool'),
                $field
            ));
        }
    }

    /**
     * @inheritDoc
     */
    public function isRequired(): bool
    {
        return true;
    }
}

```
