[dfv] Questions on writing my own contraints
Status: Inactive
Brought to you by:
markjugg
|
From: Jonas B. N. <jo...@gm...> - 2008-06-11 19:49:48
|
Hello, I am somewhat a heavy user of (out of the box) Data::FormValidator. I am currently attempting to port some of my CPAN code, which has validation behavior to Data::FormValidator::Constraints::* modules. I have followed the documentation and everything seems to work, but I feel I am missing something, I have examined several of the other implementations of constraints on CPAN, but this has not made me completely confident in how Data::FormValidator works or at least expect me to do things. So I have a few questions, please bear with me since some of this things my be obvious, but I have just not understood the concept completely. I have a constraint module. It exports by request: valid_cvr, this validates whether a given parameter is a valid cvs according to an algorithm implemented in Business::DK::CVR. At the same time I want to support untainting, in that sense that if any of the flags: - untaint_all_constraints - untaint_constraint_fields Are set to true, this is also recommended in the POD. So I have implemented: match_cvr, also exported by request. The only thing this method does is match against the data for a certain format, no actual validation is done (see: valid_cvr above). The implementations I have seen seem to have implemented either valid_ or match_ as a thin wrapper for the other, so I am unsure as to I need to separate the two, which lead to the following questions. 1. If a user defines a profile with a field named cvr, would match_cvr be used to untaint this magically and would this not require default export? I can see a scenario where the user is only interested in untainting data not necessarily validating, so the separation in implementation makes sense in my opinion 2. It seems as if a validation, results in auto-untainting, according to my tests, where match_cvr is not called at all, so match_cvr does not need to be wrapped, is there any policies regarding this I should be aware of So to sort of wrap this way too long mail up, I am unsure as to what the role and when a match_ method should be implemented and called. Let me know if I am unclear, but I have spent a lot of time writing tests to sort of try to get my head around writing my own constraints. Thanks, jonasbn -- pauseid: JONASBN email: jo...@cp... blog: http://use.perl.org/~jonasbn/journal/ |