
Incorrect initialization pattern in validators
Reported by Maxim Kulkin | June 30th, 2009 @ 01:59 AM | in 0.10.0
DataMapper::Validate::GenericValidator declares a "field_name" attribute and receives corresponding argument to constructor. But that argument is not used and "field_name" attribute initialization is done in every subclass (like RequiredFieldValidator, LengthValidator, etc.).
Also, storing options (the second constructor's argument) is such a common option that it could be moved into GenericValidator too.
Proposal:
- Implement storing value for field_name in GenericValidator
constructor.
- Add protected "options" attribute to GenericValidator and
initialize @options instance variable in constructor with
constructor's second argument.
- Remove @field_name and @options initialization from GenericValidator subclasses.
Impact:
Behavior of existing third-party validator classes will not be changed.
Comments and changes to this ticket
-
Dan Kubb (dkubb) July 3rd, 2009 @ 02:53 AM
- State changed from new to not-applicable
This appears to be resolved in the 0.10 series (the "next" branch). Closing this ticket.
If you are seeing this problem in the next branch, please add a comment with file/line numbers and I will reopen this ticket.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »