Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tokens for failureMessage for dynamic text replacement #55

Open
dswitzer opened this issue Jul 7, 2011 · 0 comments
Open

Add tokens for failureMessage for dynamic text replacement #55

dswitzer opened this issue Jul 7, 2011 · 0 comments
Labels

Comments

@dswitzer
Copy link

dswitzer commented Jul 7, 2011

We need a way to dynamically replace text tokens in a failureMessage so it can be replaced with properties from the validation rule. For example, a typical rule might look like:

<property name="Name" desc="Name">
    <rule type="required" contexts="*" />
    <rule type="maxLength" failureMessage="The name field can not be longer than 50 characters.">
        <param name="maxLength" value="50" />
    </rule>
</property>

The problem is when you write the "failureMessage" you end up having to duplicate several values based on properties in the validation rule. So if the description of the field every changes or you adjust the maxLength property and forget to mirror the changes in your failureMessage, the information becomes out of date.

What we need to is a token system that would allow us to change the failureMessage to something like:

The {property.name} field can not be longer than {rule.maxLength} characters.

(NOTE: The tokenizer should probably have some syntax for specify case. In many cases users might want to force a token's text to lower case.)

This not only makes the failureMessage more future proof, but you could use the exact same syntax for all matching validation rules, since the text would be dynamically updated with the correct text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant