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

support for variables in message: "just <x> characters to go for the title" #208

Open
0xgeert opened this issue Feb 19, 2014 · 3 comments
Open

Comments

@0xgeert
Copy link

0xgeert commented Feb 19, 2014

Would we great to have support for (mustache) expansions/variables in validation messages to do something like "just <x> characters to go for the title

@platinumazure
Copy link

Maybe this feature request could be combined with pull request #199 somehow? Seems like allowing msg to be a function wouldn't be a terrible idea... although in this case the function should be called with something like (value, validator, computed) and the other case would accept a string...

Presumably the framework could be tweaked where if msg was a string, it could turn into _.constant(theString) on the backend and silently discard those arguments, but an actual specified function would have enough information to generate those sorts of messages?

@blikblum @chiefGui Thoughts? If you're interested I could open a pull request to start the discussion, though I could use suggestions on what values should be passed to the message function.

@blikblum
Copy link
Contributor

I think allowing a function with params is the way to go. It will handle the use case of this issue

@platinumazure
Copy link

I might open a separate issue just on how "default messages" (even if overridden) are handled differently from what I might call "inline messages" (per-validator). Inline messages can be functions returning strings, but are called with no parameters (via _.result) and this is set to the validator object. Default messages must be strings and have the private format function called by the default validators (supporting {0} style formatting). It would be awesome to get those unified.

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

No branches or pull requests

3 participants