Best way to ensure custom profile property advanced validation?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
12/29/2008 3:32:37 AM
Gravatar
Total Posts 55

Best way to ensure custom profile property advanced validation?

Hi!

In my MP application, I have single custom profile property called business identifier. It is 13-digit string for crafts (craft owner's unique personal ID, something like social security number in US, with generating algorithm adjusted to pre-information age) and 7-digit string for companies (company unique ID). Both of these numbers will be replaced during this year with new unique identifier, 11-digit string called OIB which will be applied to both persons (and their crafts), including foreign citizens in need of such identifier, and companies.

Validating all those number to be digit-only is not a problem and is described here. However, all those IDs can be subject to further validation. For example, OIB falls under ISO 7064 standard for which validation code (in java & javascript) can be found here.

It would be handy if I could do such validation when registering user, in addition to digit-only and length validation via regex. It would be even more handy if I could do it using my custom feature because I like being connected to MP SVN and not thinking much about reapplying my changes to MP core whenever I get the MP latest version.

So, what would be the best way to do that?

  1. Should I add my administrative feature and link it to admin menu as described here?
  2. Or could I somehow accomplish that goal using user registered event handler? With this approach, can I somehow actually stop user registration (prevent submitting form,  that kind of thing) if user's business identifier is invalid?

 

12/29/2008 6:17:41 AM
Gravatar
Total Posts 18439

Re: Best way to ensure custom profile property advanced validation?

Hi Slaven,

I think the strategy  would use to solve this problem is first create an ISettingControl for this property. Just make a UserControl, and implement ISettingControl which is a very simple interface with 2 methods SetValue and GetValue. For an example of ISettingControl see /Controls/GMapTypeSetting.ascx

You could even add this control to a profile like this:

<add name="MapType"
type=""
iSettingControlSrc="~/Controls/GMapTypeSetting.ascx"
labelResourceKey="Map Type"
requiredForRegistration="true"
/>

Then what I would try is adding custom validator control(s) inside the UserControl, set the ValidationGroup to "profile" so it connects with the rest of the validation group.

Then implement a custom validator control, ideally with both client side validation using the javascript you found and server side validation. Implemeting this custom validator is probably the mosty challenging part, but if you can do that this solution should meet your requirements fully.

I would not try using the user registered event handler as that fires after registration is successful.

Hope this helps and Thanks for the beer!

Joe

1/1/2009 1:18:24 PM
Gravatar
Total Posts 55

Re: Best way to ensure custom profile property advanced validation?

Thanks for info!

I'll try it as soon as I get time (currently, it's not first priority) and announce results on this thread.

You must sign in to post in the forums. This thread is closed to new posts.