Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Is there any way to implement a validator for DataObjectDecorators?


Go to End


5 Posts   2002 Views

Avatar
Markus

Google Summer of Code Hacker, 152 Posts

6 August 2007 at 8:28pm

Edited: 06/08/2007 8:30pm

Since no one was answering to my post in the GSoC forum I'll try it here :-)

For OpenID support I implemented a DataObjectDecorator, but I couldn't figure out how I can add a custom validator to it. I need to ensure that the entered OpenID is unique so that only one user account is linked to a specific OpenID. Is that somehow possible?

At the moment I prevent duplicate OpenIDs by using a unique-index, but no error message will be shown.

Is there any way to implement a validator for DataObjectDecorators or handle such database errors ("Duplicate entry 'http://markus-lanthaler.myopenid.com/' for key 2")?

This would help me a lot to complete OpenID support!

Avatar
laktek

Google Summer of Code Hacker, 76 Posts

7 August 2007 at 1:16am

Edited: 07/08/2007 1:16am

Not sure whether you're looking for a similar solution but thought this would shed some light ;)

I saw in ForumRole.php, implemented a ForumMember validator extending Member_Validator and overriding the getValidator function inside ForumRole.

Similarly can't you extend the Member_Validator and add php() function with necessary validation which is to executed server-side ?

Avatar
Markus

Google Summer of Code Hacker, 152 Posts

7 August 2007 at 1:56am

Edited: 07/08/2007 2:12am

Thanks for you reply Lakshan!

> I saw in ForumRole.php, implemented a ForumMember validator extending
> Member_Validator and overriding the getValidator function inside ForumRole.
>
> Similarly can't you extend the Member_Validator and add php() function with necessary
> validation which is to executed server-side ?

That was also my first thought and so I tried that already but unfortunately that is code that isn't executed at all.
It doesn't do anything in the ForumRole so that code is also buggy..

I forgot to post a bug report about that to the bugs forum (will do that now).

Edit: I posted it to the bugs forum and created a ticket.

Avatar
Markus

Google Summer of Code Hacker, 152 Posts

21 August 2007 at 9:46pm

I talked about that yesterday with Hayden.. he is searching a solution.

Since I didn't get any answer and the GSoC is over now, I assigned the ticket to Hayden (my mentor).

Avatar
Markus

Google Summer of Code Hacker, 152 Posts

28 August 2007 at 1:05am

OK, I fixed that problem in r40925. It's not the best (scalable) solution but it works for the moment and Hayden said that I should not change the core's validation behavior at the moment.