-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zip format for Italy #22
Comments
Hi @masetto , here are some answers:
|
@nganivet thank you for your answer. I worked on that: 9f66528 Now I'm thinking to work about validation of phone and postal code: your extension simply notify with a message and do not block if a user write a wrong postal code or phone number. Is it intentional? About no. 3: I'm thinking to add in extension setting an option to add the invalid postal code (and why not phone number?) contacts in a group specified by the user. What do you think? |
@masetto Yes, it is intentional that we do not block the user. This validation is done from a hook, we do not know if it was triggered by a front-end form, a back-end user, a cron job or an API call, so we cannot 'block' the action. It is a good idea to implement on-screen validation for the CiviCRM zip-code entry field, but that would need to integrate differently in CiviCRM. It seems like a great idea to have the option to put contacts in a group, that is a good alternative to sending emails. |
I saw that there is the extension Phone Input Mask and I was thinking of adding an option to validate the phone number and the postal code in forms, like that extension. So we can implement the validateForm hook for these form:
The advantage would be to use a single extension... |
@masetto I did not know about the Phone Input Mask extension, thanks for pointing it out. I would rather have the option to validate the zip codes be rolled into this other extension than adding it here. This way the Normalize extension stays focused on normalizing/validating data once submitted, and the Phone Input Mask deals with the collection and submission in the front-end. |
The phone input mask is specifically for formatting phone numbers in the backend. So back office users get a message when they a enter a non-formatted phone number. So it does not do any normalization of data. It also has a configuration screen to configure which formats are valid formats. |
Yes, how it works phone input mask was clear. In any case, I would also need the validation of the postal code and I would not want to create an extension only for that. |
@masetto Not quite sure about what you are suggesting, but you are welcome to do a PR. @jaapjansma Sorry I misunderstood. I thought your extension provided an input mask on the HTML form widget, similar to when you enter dates or credit card numbers some widget limit accepted chars and insert additional characters as you type. I see now that this is not the case, so there is substancial overlap between our extensions. My extension mainly does auto-reformatting based on configured policy (ie. enter jajp jansma and it will save Japp JANSMA in the database), but validation features were also added later on, primarily for zip codes. Ideally we would need the following functions (for US zip code field as example):
Phone numbers will be a bit more complex, but still have the need for the entry mask, validation and normalization features. These features are vastly different in terms of implementation, so could potentially be delegated in different extensions. @masetto outlines the need for common elements between these features. There certainly is symbiosis between entry mask and validation, but I am not sure there is symbiosis with normalization. |
Actually, there is: normalization should validate the field before even trying to reformat it ... makes sense! |
I'd like to add Italy zip format and also other interventions to support Italian telephones and addresses.
But first I would like to understand why:
$country == 'CA'
? I think it is a typoThanks
The text was updated successfully, but these errors were encountered: