ember-cp-validations icon indicating copy to clipboard operation
ember-cp-validations copied to clipboard

Feature Request: support multiple messages (or warningMessages) from validators

Open mwpastore opened this issue 5 years ago • 2 comments

Since an attribute can have multiple messages from multiple validators, it doesn't seem too far fetched to add support for multiple messages from a single validator. For example, I have a custom password strength validator (based on zxcvbn) that can provide multiple suggestions back to the user to improve password strength. If I try to return multiple messages today it seems to get awkwardly stringified, and it breaks the ability to iterate over the messages in an Ember template.

What I'd really like is the ability to return a collection of results that can include both warning results and non-warning results. The validation would be considered invalid if the collection included any non-warning results. That would be a more significant change based on my reading of the source.

mwpastore avatar Oct 20 '18 17:10 mwpastore

I was able to work around my first request by boxing my array of messages in an object:

return { warningMessage: feedback.suggestions, isValid: true };

And I was able to work around my second request by applying my custom validator to the attribute twice: once with isWarning and once without.

mwpastore avatar Oct 22 '18 13:10 mwpastore

Not sure if this helps your issue but I had a similar issue with the warning/error messages and stumbled upon this solution: https://github.com/offirgolan/ember-cp-validations/issues/581#issuecomment-391636533

It worked for me then.

freyjameetsmel avatar Oct 26 '18 13:10 freyjameetsmel