Validators Feature Request

Validators Feature Request

Old forum URL: forums.lhotka.net/forums/t/7279.aspx


cdkisa posted on Wednesday, July 15, 2009

I'm not sure if this is the right place to request a feature or not. If not, then sorry. Maybe this should go to the CSLA.contrib project?

I would like to request an improvement/change to the "RuleArgs" that are passed into validation methods. The request is to have a standard parameter/property added to pass in a custom message. This would allow developers to supply custom error messages instead of relying on the built in messages provided by Rocky. This would also allow localization/internationalization for applications.

For example:
The current (English) message that is used when a RegExMatch fails is: {0} does not match regular expression. While this is suitable for users who know what a regular expression is, it does not provide enough information for a user to correct the information that caused the validation to fail in the first place. By allowing developers to pass in a custom error message, we could provide a more informational and specific message to the end user, such as: Phone numbers must be formatted as (123) 456-7890.

The PROS:
- language independant
- Rocky no longer has to maintain multiple language resource files
- developers/end users have more control

The CONS:
- developers have to provide their own language support (more development time)
- developers can't be lazy about writing meaningful error messages

I can provide an example if necessary.

What do you think?

Cheers

RockfordLhotka replied on Thursday, July 16, 2009

I think this is already in the wish list, and it is a good idea, at least for the RegEx rule. It isn't clear to me that it is great for all rules, because it pushes the description up into the business object and increases the coupling between the rule and the caller (because the caller needs to know what replacement tokens must be supplied to make the Format() method work).

Copyright (c) Marimer LLC