src/Factory/Validator/BirthdayValidatorFactory.php
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $validatorChain = new ValidatorChain();

        $intl = new IntlDateFormatter(
            Locale::getDefault(),
            IntlDateFormatter::LONG,
            IntlDateFormatter::NONE
        );

        $date = (new DateTime('now'))->modify('-100 years');
        $validatorChain->attachByName('GreaterThan', [
            'messages' => [
                GreaterThan::NOT_GREATER_INCLUSIVE => 'The date of birth '
                    . 'must be not earlier than %min% inclusive',
            ],
            'messageVariables' => [
                'min' => ['abstractOptions' => 'fmt'],
            ],
            'min' => $date->format('Y-m-d'),
            'fmt' => $intl->format($date),
            'inclusive' => true,
        ], true);

        $date = (new DateTime('now'))->modify('-18 years');
        $validatorChain->attachByName('LessThan', [
            'messages' => [
                LessThan::NOT_LESS_INCLUSIVE => 'The date of birth '
                    . 'must be not later than %max% inclusive',
            ],
            'messageVariables' => [
                'max' => ['abstractOptions' => 'fmt'],
            ],
            'max' => $date->format('Y-m-d'),
            'fmt' => $intl->format($date),
            'inclusive' => true,
        ], true);

        return $validatorChain;
    }
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $validatorChain = new ValidatorChain();

        $intl = new IntlDateFormatter(
            Locale::getDefault(),
            IntlDateFormatter::LONG,
            IntlDateFormatter::NONE
        );

        $date = (new DateTime('now'))->modify('-100 years');
        $validatorChain->attachByName('GreaterThan', [
            'messages' => [
                GreaterThan::NOT_GREATER_INCLUSIVE => 'The date of birth '
                    . 'must be not earlier than %min% inclusive',
            ],
            'messageVariables' => [
                'min' => ['abstractOptions' => 'fmt'],
            ],
            'min' => $date->format('Y-m-d'),
            'fmt' => $intl->format($date),
            'inclusive' => true,
        ], true);

        $date = (new DateTime('now'))->modify('-18 years');
        $validatorChain->attachByName('LessThan', [
            'messages' => [
                LessThan::NOT_LESS_INCLUSIVE => 'The date of birth '
                    . 'must be not later than %max% inclusive',
            ],
            'messageVariables' => [
                'max' => ['abstractOptions' => 'fmt'],
            ],
            'max' => $date->format('Y-m-d'),
            'fmt' => $intl->format($date),
            'inclusive' => true,
        ], true);

        return $validatorChain;
    }
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ validatorChain = new ValidatorChain ( ) ; $ intl = new IntlDateFormatter ( Locale :: getDefault ( ) , IntlDateFormatter :: LONG , IntlDateFormatter :: NONE ) ; $ date = ( new DateTime ( 'now' ) ) -> modify ( '-100 years' ) ; $ validatorChain -> attachByName ( 'GreaterThan' , [ 'messages' => [ GreaterThan :: NOT_GREATER_INCLUSIVE => 'The date of birth ' . 'must be not earlier than %min% inclusive' , ] , 'messageVariables' => [ 'min' => [ 'abstractOptions' => 'fmt' ] , ] , 'min' => $ date -> format ( 'Y-m-d' ) , 'fmt' => $ intl -> format ( $ date ) , 'inclusive' => true , ] , true ) ; $ date = ( new DateTime ( 'now' ) ) -> modify ( '-18 years' ) ; $ validatorChain -> attachByName ( 'LessThan' , [ 'messages' => [ LessThan :: NOT_LESS_INCLUSIVE => 'The date of birth ' . 'must be not later than %max% inclusive' , ] , 'messageVariables' => [ 'max' => [ 'abstractOptions' => 'fmt' ] , ] , 'max' => $ date -> format ( 'Y-m-d' ) , 'fmt' => $ intl -> format ( $ date ) , 'inclusive' => true , ] , true ) ; return $ validatorChain ; }
{@inheritDoc}

@return ValidatorInterface
{ @inheritDoc }