MotoValidation 2.1 (itsy-bitsy edition)

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.

Get it on GIT

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:

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.


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

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:

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...

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">