Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Custom error messages #89

Open
speedygfw opened this issue Nov 30, 2012 · 0 comments
Open

Custom error messages #89

speedygfw opened this issue Nov 30, 2012 · 0 comments

Comments

@speedygfw
Copy link

The error messages are not ready for custom localization.

I use this hack in my version:

validator.js

parseMessage: function(msg, obj)
    {
        var res = msg.replace('{value}', obj.value).replace('{label}', obj.label);
        return res;
    },

all validators:

  var err = M.Error.extend({
                    msg: this.msg ? this.parseMessage(this.msg, obj) : key + ' is required and is not set.',
                    code: M.ERR_VALIDATION_PRESENCE,
                    errObj: {
                        msg: this.msg ? this.parseMessage(this.msg, obj) : key + ' is required and is not set.',
                        viewId: obj.id,
                        validator: 'PRESENCE',
                        onSuccess: obj.onSuccess,
                        onError: obj.onError
                    }
                });

so you can do this:

M.PresenceValidator.msg = "{label}: your custom message.";




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

No branches or pull requests

1 participant