This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Validator with Zend\I18n\Validator\DateTime is always required #49
Comments
I cannot reproduce. To attempt to reproduce, I added zend-i18n as a dev dependency (
public function testUnrequiredDateTimeValidatorShouldNotResultInInvalidationOfSet()
{
$services = new ServiceManager();
$factory = new InputFilterFactory();
$services->setService('FooValidator', $factory->createInputFilter([
'dateField' => [
'name' => 'dateField',
'required' => false,
'validators' => [
[
'name' => DateTime::class,
'options' => [
'pattern' => 'Y-m-d\TH:iP',
'message' => 'Invalid date format',
],
],
],
'allow_empty' => true,
'continue_if_empty' => true,
'description' => 'Date Field',
],
]));
$listener = new ContentValidationListener(
[
'Foo' => [
'GET' => 'FooValidator',
],
],
$services,
['Foo' => 'foo_id']
);
$request = new HttpRequest();
$request->setMethod('POST');
$matches = $this->createRouteMatch(['controller' => 'Foo', 'foo_id' => 3]);
$dataParams = new ParameterDataContainer();
$dataParams->setBodyParams([
'name' => 'Joe Public',
'email' => '[email protected]',
]);
$event = new MvcEvent();
$event->setRequest($request);
$event->setRouteMatch($matches);
$event->setParam('ZFContentNegotiationParameterData', $dataParams);
$this->assertNull($listener->onRoute($event));
$this->assertNull($event->getResponse());
}
The test passed. Can you update your dependencies and report back if the problem still exists? If it does, we'll need more information. |
This repository has been closed and moved to laminas-api-tools/api-tools-content-validation; a new issue has been opened at laminas-api-tools/api-tools-content-validation#7. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I am attempting to use the DateTime validator in an Apigility project. The configuration is set to not be required and continue if empty, however the validator always returns a validation error.
Input
Validator configuration
Error message
The text was updated successfully, but these errors were encountered: