Help with Validation setup

8 views
Skip to first unread message

Joel Hughes

unread,
Nov 6, 2017, 12:26:01 PM11/6/17
to foam-framework-discuss
What setup is required for Validation via the ValidationDAODecorator?

Our validateObj(s) are called.  Not sure how to cause put to reject.  It's my impression that validateObject() is meant to validate the complete object not just a single property as with validateObj but I'm not sure what method in my model I should implement to work with validateoObject.

Thanks
Joel 

We are wrapping our DAO(s) with
            if (info.validate) {
                var decorated = this.DecoratedDAO.create({
                    decorator: this.ValidationDAODecorator.create({
                        dao: dao
                    }, this),
                    delegate: dao
                }, this);
                dao = decorated;
            }


and we have validateObj
        {
            name: "email",
            class: 'String',
            required: true,
                          validateObj: function(email) {
                // TODO: proper email regex
                return email.length > 3;
            }
        },



Joel Hughes

unread,
Nov 7, 2017, 7:57:04 AM11/7/17
to foam-framework-discuss
validateObj is now displaying an alert. It's empty and I cannot figure out where it's generated from. 

        {
            name: "email",
            class: 'String',
            required: true,
            validateObj: function(email, label) {
                               return label + ' email error message';
            }
        },


Thanks
Joel 
Reply all
Reply to author
Forward
0 new messages