[pLog-svn] validator help

Jon Daley plogworld at jon.limedaley.com
Tue Jan 24 19:44:52 GMT 2006


On Tue, 24 Jan 2006, Oscar Renalias wrote:
>> 	I want to validate the user typed in subdomains a couple of ways.
>> One, I want a simple check against the forbidden_usernames list.
>> And then I want to remove bad characters, and translate ones I can using 
>> the new domainize function. Then I want to run the forbidden_usernames list 
>> again.
>> 
>> I wrote a domainValidator that does what I want, and catches it if I type 
>> in directly "www (.domain.com)", but if I type in "www- (.domain.com)" it 
>> doesn't catch it, so then domainize strips the trailing -, and then my 
>> copied domainvalidator code into adminupdateblogsettingsaction catches the 
>> failure, and returns FALSE, out of the perform function.
>> 
>> But, the data has not been saved, and so *all* values on the page revert to 
>> what they were before I hit the submit button, which is annoying.
>> I basically just want to run the validator again, and have it put the error 
>> text next to the field that is wrong, and leave all other text the way the 
>> user just typed it in, so he doesn't have to retype it.

> So what you're saying is that the value that was typed in the text field is 
> not being returned back to the form in case of validation errors?
 	No. :)  I know how to do a regular validator like you say.  If I 
make the validator dependent on LifeType code, that fixes part of the 
problem.  The other part is because the validator isn't allowed to modify 
the data, he has to locally modify it (trim off/translate various 
characters) then run the "real" validator.  And then updateblogsettings 
code will do the same trimming/replacing.  So, as long as the two trimmers 
are identical, everything is fine.  Maybe I can include another function 
in the domain validator that the updateblogsettings->perform can call, so 
then I am sure the two pieces are in sync.  Does that make sense?

> But what we shouldn't do is allow validators to modify data that they're 
> being asked to validate...
 	Right.  But, perhaps it is okay to locally modify it before 
running the validator.

> Ask if you need more help, or show us the code and we'll try to help :)

Code is here:
http://devel.limedaley.com/blog_domain/class/action/admin/adminupdateblogsettingsaction.class.phps 
basically, I want to move the code below "// check to see whether we are 
going to save subdomain information" into the validator, which I am now 
thinking is probably fine.




More information about the pLog-svn mailing list