Skip to content

Commit

Permalink
Merge pull request #3 from zf-fr/vies-validator
Browse files Browse the repository at this point in the history
Add VIES validator
  • Loading branch information
bakura10 committed Jan 27, 2015
2 parents 96b451c + ba76a2a commit 303a732
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 30 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0
## 1.0.0-beta.2

* Add a validator for VIES european codes

## 1.0.0-beta.1

* Initial release
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,38 @@ $this->subscriptionDiscountService->remove($discount);
Finally, the service offers several getters you can use:

* `getById`: get the discount by its id
* `getBySubscription`: get the discount of a given subscription
* `getBySubscription`: get the discount of a given subscription

### MISC

ZfrCash comes with a validator for european VAT numbers (VIES). For instance, if you have an input filter, you
can add the validator:

```php
$inputFilter->add([
'name' => 'tax_number',
'required' => false,
'validators' => [
['name' => ViesValidator::class]
]
]);
```

By default, the validator only follow rules for correct format, but do not enforce the real existence of the VAT
number. This needs to do an additional call to the VIES webservice. To enable this, you can use the option
`check_existence`:

```php
$inputFilter->add([
'name' => 'tax_number',
'required' => false,
'validators' => [
[
'name' => ViesValidator::class,
'options' => ['check_existence' => true]
]
]
]);
```

However, please note that from my experience, the VIES webservice is HIGHLY unreliable and often fails.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"doctrine/orm": "~2.5",
"doctrine/doctrine-module": "~0.9",
"zfr/zfr-stripe-module": "~3.0",
"ddeboer/vatin": "1.3.*",
"zendframework/zend-mvc": "~2.2",
"zendframework/zend-http": "~2.2",
"zendframework/zend-eventmanager": "~2.2",
Expand Down
143 changes: 127 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 55 additions & 12 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@
use ZfrCash\Service\PlanService;
use ZfrCash\Service\SubscriptionDiscountService;
use ZfrCash\Service\SubscriptionService;
use ZfrCash\Validator\ViesValidator;

return [
/**
* --------------------------------------------------------------------------------
* SERVICE MANAGER CONFIGURATION
* --------------------------------------------------------------------------------
*/

'service_manager' => [
'factories' => [
CardService::class => CardServiceFactory::class,
Expand All @@ -50,6 +57,32 @@
]
],

/**
* --------------------------------------------------------------------------------
* DOCTRINE CONFIGURATION
* --------------------------------------------------------------------------------
*/

'doctrine' => [
'driver' => [
'zfr_cash_driver' => [
'class' => XmlDriver::class,
'paths' => __DIR__ . '/doctrine',
],
'orm_default' => [
'drivers' => [
'ZfrCash\Entity' => 'zfr_cash_driver',
],
],
],
],

/**
* --------------------------------------------------------------------------------
* ROUTER CONFIGURATION
* --------------------------------------------------------------------------------
*/

'router' => [
'routes' => [
'stripe-webhook' => [
Expand Down Expand Up @@ -85,26 +118,36 @@
]
],

/**
* --------------------------------------------------------------------------------
* CONTROLLERS CONFIGURATION
* --------------------------------------------------------------------------------
*/

'controllers' => [
'factories' => [
WebhookListenerController::class => WebhookListenerControllerFactory::class
]
],

'doctrine' => [
'driver' => [
'zfr_cash_driver' => [
'class' => XmlDriver::class,
'paths' => __DIR__ . '/doctrine',
],
'orm_default' => [
'drivers' => [
'ZfrCash\Entity' => 'zfr_cash_driver',
],
],
],
/**
* --------------------------------------------------------------------------------
* VALIDATORS CONFIGURATION
* --------------------------------------------------------------------------------
*/

'validators' => [
'invokables' => [
ViesValidator::class => ViesValidator::class
]
],

/**
* --------------------------------------------------------------------------------
* ZFR CASH CONFIGURATION
* --------------------------------------------------------------------------------
*/

'zfr_cash' => [
// Object manager key
'object_manager' => 'doctrine.entitymanager.orm_default',
Expand Down
Loading

0 comments on commit 303a732

Please sign in to comment.