diff --git a/src/NotEmpty.php b/src/NotEmpty.php index 066fe0b2..3cc301bc 100644 --- a/src/NotEmpty.php +++ b/src/NotEmpty.php @@ -260,4 +260,22 @@ public function isValid(mixed $value): bool return true; } + + /** + * Return the configured message templates + * + * This method is an affordance to laminas-inputfilter. + * It needs to introspect configured message templates in order to provide a default error message for empty inputs. + * + * In future versions of laminas-validator, this method will likely be deprecated and removed. Please avoid. + * + * @internal + * + * @psalm-internal \Laminas + * @return array + */ + public function getMessageTemplates(): array + { + return $this->messageTemplates; + } } diff --git a/test/NotEmptyTest.php b/test/NotEmptyTest.php index 799decac..c8c3268a 100644 --- a/test/NotEmptyTest.php +++ b/test/NotEmptyTest.php @@ -695,4 +695,13 @@ public static function arrayConfigNotationWithoutKeyProvider(): array [null, true], ]; } + + public function testRetrievalOfMessageTemplates(): void + { + /** @psalm-suppress InternalMethod */ + $templates = (new NotEmpty())->getMessageTemplates(); + self::assertNotSame([], $templates); + self::assertArrayHasKey(NotEmpty::IS_EMPTY, $templates); + self::assertArrayHasKey(NotEmpty::INVALID, $templates); + } }