<?php

declare(strict_types=1);

namespace Apexl\Io\Validation\Collections;

use Apexl\Io\Validation\ValidationRules\ValidationRule;
use Arrayy\Collection\AbstractCollection;
use Arrayy\Type\TypeInterface;

final class ValidationRuleCollection extends AbstractCollection implements TypeInterface
{

    public function getType(): string
    {
        return ValidationRule::class;
    }

    public function toFormKitString(): string
    {
        return $this->map(fn(ValidationRule $validation): string => $validation->toFormKitValidatorString())
            ->filter()
            ->implode('|');
    }

    public function toValidationString(): string
    {
        return $this->map(fn(ValidationRule $validation): string => $validation->toValidatorString())
            ->filter()
            ->implode('|');
    }
}