For "zip code" do you mean US zipcodes? UK postcodes? Any of them? All of them?
I think if there is a "standard zipcode" definition within your company/project/application, then those for attributes are related, and it would make sense to create an separate class for dealing with them. But I would assume such a class to have considerably more functionality that just validation.
If the only constraint on those disparate fields is that they must be positive integers (what size?), then you can probably get away with making them a type.
However, if we are talking about 4 truely disparate and unrelated attributes of 4 truely unrelated classes, that just happen to require a similar type of validation--at the moment--then it would be downright dangerous to use a common routine for performing that vaidation. As soon as one of them changes, the nature of their unrelatedness is likely to cause the the maintenance programmer to modify the validation routine commesurate with the one that changed and be completely oblivious to the other three which haven't.
Finally, if there are sound reasons for using a single vaidation routine for the 4 disparate attributes, I would just call that routine within the second code block of the LVALUE keyword I described. It in no way precludes that.
In reply to Re^19: Assignable Subroutines
by BrowserUk
in thread Assignable Subroutines
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |