Hi,
I think VAT is a cool module. But my first nag with it is that it isn't extensible.
- The first issue in the projects' issue queue is a feature request to add the german VAT validation.
- it only supports BE and NL VAT validation and those are hardcoded into the module.
So, I took the challenge to make the module extensible.
Here's how it works:
1. Use the patch below
2. Add the vat_validators module in a separe module folder or put it in the VAT module folder.
3. rename vat_validators.txt to vat_validators.module
4. Enable the VAT Validators module
5. When you create a new CCK VAT field, you can now select for which countries you want to apply VAT validation. The module supports validation against multiple countries at the same time.
If you want to implement your own VAT validator (like the German one) but you don't want to hack into the module or bother the maintainers to implement validation.
1. Create a new module
2. implement hook_vat_info Take a look at vat_validators.module to see how it should be done.
3. write your own VAT validator.
It's a bit crude, but it's enough to get you started. :)
| Comment | File | Size | Author |
|---|---|---|---|
| vat_validators.txt | 936 bytes | netsensei | |
| vat_validators.info | 157 bytes | netsensei | |
| vat-extensible.patch | 3.57 KB | netsensei |
Comments
Comment #1
jax commentedI'll have look at this asap. This will probably also be related to #837434: Separate validation functions into separate API
Comment #2
netsensei commentedYup. It's exactly the same in terms of requested functionality. Recommend to rename this issue and set the other one as a dup.
Comment #3
jax commentedMarked #837434: Separate validation functions into separate API as dupe.
Comment #4
jax commentedMy first feeling about the proposed implementation is that it's overkill. What happens when you have multiple validators for one country? Should they all be executed? Isn't it better to group all the validators in this module? The proposed patch does make it more extensible but does not really provide an API for other modules to use if they want to validate their own VAT fields (like ubercart).
If we go this route we should also provide a hook_vat_info_alter().