So after some battle testing I found that the validation engine needed some polish as well as some 40″ spinners and one of the hula dancers you stick to your dashboard.
For those of you that are new check out the documentation in v2.0 first.
Besides fixed a few bugs we added some great new functionality as well.
New stuff:
Clearing out the Validation List
I found that I love the custom function it’s a super easy way to add custom validation to my list BUT (that’s a big but… 😉 ) if you write a crappy function, like all programmers are prone to do once in a while, it’ll hold that crap indefinitely on the server.  So I added a clear out function.  This little dandy is quite useful for those of us who are not perfect (but try).
For example I wrote this little dream:
motoValidation.setBaseObject({name:"tw.local.requestObject", value:tw.local.requestObject}); motoValidation.addFieldValidation("numberOfContainers",[],"custom", "Number of Containers must be more than 0.", function(value){ if(vlaue > 0){ return true; }else{ return false; } }); motoValidation.validation();
Any goon could see that I’ve spelled “value” wrong in line 3. Â The thing got tricky because since this project was built as a javascript module the server saved the state of the variable which means that unless I manually told the module to clear out my storage array for field validation that little sucker was gonna stay there. Â Thus was born the clearValidateFields()Â function.
motoValidation.clearValidateFields();
Even Smaller
So I’ll admit as much as I love my nickname after typing motoValidation.addFieldValidation… like 10 times I was over it. Â SO (da-da-da-daaaa) I’ve shortened all the major functions. Â You can now write the following shorthand to save your self time:
- motoValidation = mV
- setBaseObject() = sBO()
- addFieldValidation() = aFV()
- addObjectValidation() = aOB()
- validate = val()
This helps us take the write less, do more concept to the next level of lazyness for example
mV.sBO({name:"tw.local.reqeustObject", value:tw.local.requestObject}); mV.aFV("customerName"); mv.aOV("parts", ["partNumber","partDescription"],"list"); mV.val();
All the power of complex validation in as few keystrokes as possible.
Base Object != tw.local
After a few hours of beating my head against the wall I finally gave in and realized that I can’t find a way to set the base object to “tw.local”. Â Turns out the the functions I use to traverse the object model in BPM don’t exist a this level SO… I made a slight twist to the script to support cases where you want to validate the base object. Â You can now do something like this:
mV.sBO({name:"tw.local.isRequestApproved", value:tw.lcoal.isRequestApproved}); mV.aFV("", [], "boolean-true"); mV.val();
To explain what’s happening… so in the example above the is isRequestApproved variable was a private boolean on my coach and it was the ONLY field I needed to validate.  I was having a hell of a time validating it because there was no getPropertyValue function available on the tw.local object SOOOO now you can validate the base object directly.  By leaving the fieldName parameter of the addFieldvalidation (aFV) function blank the engine now assumes you want to validation the base object itself.  And in the case above I want to ensure that the boolean was true.  This applies to the addObjectValidation function as well.
Have fun!
Tell me what you REALLY think...