<?php

namespace Planaday\Utility\DataFilters\Validators;

class NotNull implements Validator {
	public function __construct(
		protected string $message = 'required field is missing'
	) {}

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

		return true;
	}

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