logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Preparing Zend_Validate_* for Export as JSON: msg#00019

Subject: Re: Preparing Zend_Validate_* for Export as JSON
FWIW, Bill just added the method getMessageVariables() to the validator base class. You can use this to get an array of most of the "config"-type member variable names. If you happened to need their current values, you grab those in a second step. However, to get write access to those, you have to do reflection (as you mentioned) and find all the setter methods.

Quote:
Bill Karwin wrote:
> But in the existing validator classes, these properties are protected
> and should be read-only.  That's the reason that __get() is provided to
> access them, and there's no __set().

BTW, I checked out that validator code you posted. It seems pretty darn useful to be able to call the validators you already have written in PHP from Javascript.

Regards,
Bryce Lohr


AHeimlich wrote:
Having the config options available as public properties would help immensely
(as long as it was consistent throughout all Zend_Validate_* classes). Then
all I would have to do is have a wrapper class use get_object_vars() on an
instance of the Zend validator it was managing. For classes like
Zend_Validate_EmailAddress (which uses an instance of Zend_Validate_Hostname
for host name validation) I could simply nest its configuration info inside
of Zend_Validate_Email's (assuming, of course, that the instance of
Zend_Validate_Hostname is available as a public property).

The only stumbling block is that I was hoping for a solution that worked now
as opposed to something that would be implemented in the future (would your
idea even make it into 1.0RC3 or 1.0 Final?). I just had an idea about
finding all of Zend_Validate_* instance's getter functions and calling them,
but I can't use that consistently as some validators (namely
Zend_Validate_EmailAddress and Zend_Validate_Hostname) don't have any getter
functions (plus, a single call to get_object_vars() sounds much better that
a call to get_class_methods() plus a call to every getter function). I would
start using this, though, if your public properties idea goes through (it
would be much easier to switch to it from my getter methods idea than from
subclasses).

Thanks a lot,

Aaron Heimlich


Darby Felton wrote:
For the Zend_Filter_* and Zend_Validate_* classes, maybe it makes less
sense to have configuration variables protected than to publicize them.

For example, I recently implemented an "allowWhiteSpace" option for the
Alnum and Alpha filter and validation classes as a public property. I do
not believe there is a hard and fast rule for whether such configuration
variables must be public or protected.

I lean toward publicizing such variables where reasonably possible.
Would this help to solve your problem?

Best regards,
Darby

AHeimlich wrote:
For my current project, I'm adapting a form-handling library that I've
been
working on[1] for use within the ZF and the project. The validation rules
in
this library are capable of preparing themselves for export as JSON by
creating an associative array of config options they want exported. These
and other things are then fed, as JSON, into a client-side validation
processor (to see it all in action go to
http://aheimlich.dreamhosters.com/HValidator/examples/javascript-integration/).

As I was working on this, I noticed that there were a lot of validation
routines that ZF has, that my library didn't and some that we share the
ZF
does differently (like how ZF's alphanumeric validators can handle UTF-8
and
mine can't) and I started wanting to take advantage of this. The problem
I've been having is that I can't seem to figure out a good way to prepare
the Zend_Validate_* classes for export as JSON (mainly because most of
the
config info I would want to export is located in protected properties).
Is
there a way to do this without subclassing the Zend_Validate_* classes?

[1] http://aheimlich.dreamhosters.com/HValidator.zip





Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
db.firebase.por...    text.xml.xalan....    qnx.openqnx.dev...    user-groups.zar...    internationaliz...    kde.devel.konve...    finance.e-gold....    emacs.latex.pre...    gis.therion/200...    web.webmin.gene...    yellowdog.gener...    vserver/2003-08...    redhat.release....    sysutils.tivoli...    xfree86.expert/...    mail.becky.user...    hardware.netapp...    netbsd.ports.xe...    python.distutil...    boot-loaders.gr...    culture.interne...    java.springfram...    activedir/2006-...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe