summaryrefslogtreecommitdiffstats
path: root/packages/meteor-useraccounts-core/lib/templates_helpers/at_error.js
blob: 5673dfe7ae516cce4b0f3d90039fb91f74b04978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
AT.prototype.atErrorHelpers = {
    singleError: function() {
        var errors = AccountsTemplates.state.form.get("error");
        return errors && errors.length === 1;
    },
    error: function() {
        return AccountsTemplates.state.form.get("error");
    },
    errorText: function(){
        var field, err;
        if (this.field){
            field = T9n.get(this.field, markIfMissing=false);
            err = T9n.get(this.err, markIfMissing=false);
        }
        else
            err = T9n.get(this.valueOf(), markIfMissing=false);

        // Possibly removes initial prefix in case the key in not found inside t9n
        if (err.substring(0, 15) === "error.accounts.")
            err = err.substring(15);

        if (field)
            return field + ": " + err;
        return err;
    },
};