javascript - meteor autoform custom validation not reactive -
i'm trying use custom validation function field defined in simpleschema, error message not render on field.
num: { type: number, label: "number", min: 1, decimal: false, // unnecessary default number, future reference autoform: { group: "info", defaultvalue: function() { //@todo - default next number logged in user return 5; } }, custom: function () { collection.simpleschema().namedcontext("addnumberform").addinvalidkeys([{name: "num", type: "numnotunique"}]); } },
i've defined custom error message it
simpleschema.messages({numnotunique: "this number has been entered"});
when submit form can confirm custom function executes, nothing changes in ui field indicating error. context name "addnumberform" got simpleschema.debug = true;
setting , seeing thrown other fields default validation.
what missing here?
after trial , error i've figured out.
the simpleschema named context necessary if manually validating using simpleschema itself. autoform takes care of this, , custom function can return simple string defines error.
num: { type: number, label: "number", min: 1, decimal: false, // unnecessary default number, future reference autoform: { group: "info", defaultvalue: function() { //@todo - default next number logged in user return 5; } }, custom: function () { // check return 'numnotunique'; // return our error } },
Comments
Post a Comment