<?php

namespace Planaday\Utility\DataFilters\Validators;

class IsTrue implements Validator {
	protected string $message;

	public function __construct(?string $message = null) {
		$this->message = $message ?? 'selected false where true is required';
	}

	/**
	 * @template T
	 * @param T $data
	 *
	 * @return string|true
	 */
	public function validate($data): string|bool {
		if ( $data === false ) {
			return $this->message;
		}

		return true;
	}

	public function getName(): string {
		return 'is_true';
	}
}