shouldValidate($data)) { (new RequiredRule())->validate($field, $value, $data); } } /** * @inheritDoc */ public function isRequired(): bool { return true; } /** * Checks if the required param matches the required value in the data. * Uses a loose comparison so the string parameter "true" also matches a * boolean request value. */ protected function shouldValidate(array $data): bool { $requiredParam = $this->parameters[0] ?? ''; $requiredValue = $this->parameters[1] ?? null; return ($data[$requiredParam] ?? null) == $requiredValue; } }