github

AS3 Open Source: Custom Form Validation

01/20/2010 in RIA Comments

During a normal week I may write 2-3 form based applications in either Flash or Flex and each of them have specific form values that need validated. Last week I decided to begin to write a custom validator in Pure AS3 that I can reuse and simply pass it an array of information to validate against. The first iteration is a simple check against a value and a parameter of what would make it invalid, for example a String and if it == “”. The validation built into Flex is “ok”, but I needed some more portable, extensible and very reusable.

I have included a sample test instantiation for using the classes, simply checking for String values, but you can pass basically anything you like to the validator and it will check the value against the parameter that would make it invalid. I am sure this will change a lot over the next few weeks as I add validation types, values and such, so I will continue to commit the source to git. I am trying to keep it as generic as possible, to use in both Flash and Flex projects. Custom events are fired on pass and fail, passing along an array of information based on the fields that failed. You can then call your methods to submit the form or throw Alerts, etc…up to you.

I have posted the initial classes on my github account with an MIT Open Source license.

You can grab the early framework or fork the repository at github here > NumbKnuckle Validator