URLValidator for AS3/Flex

I had the need for a URL Validator for a Flex project, and couldn’t find one. So, here’s the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.iotashan.validators
{
    import mx.validators.ValidationResult;
    import mx.validators.Validator;
   
    public class URLValidator extends Validator
    {
        public function URLValidator()
        {
            super();
        }
       
        override protected function doValidation(value:Object):Array
        {
            // Clear results Array.
            var results:Array = [];

            // Call base class doValidation().
            results = super.doValidation(value);       
            // Return if there are errors.
            if (results.length > 0)
                return results;
           
            // match regex pattern
            var pattern:RegExp = new RegExp("^http[s]?\:\\/\\/([^\\/]+)\\/");
            // run the pattern, but don't error if there is no value and this is not required
            if (!(!required && !value) && !pattern.exec(String(value))) {
                results.push(new ValidationResult(true, null, "notURL",
                    "You must enter a valid URL."));
                return results;
            }
           
            return results;
        }
    }
}

You can download the swc here.

cf-flex-user-auth Released

I’m happy to announce the immediate availibility of cf-flex-user-auth, a starter application for developers building Flex applications with ColdFusion on the backend. I’ve been working on this for a while now, and it’s gone through two complete rewrites.

The idea behind this is for developers to be able to download this source code, and have a running start at building Flex applications. On the Flex side, we’re using the Mate framework. On the ColdFusion end, we’re not using any framework, since we’re really only exposing the database via CFC’s.

This application covers the basics of a user application, because I was tired of rewriting the wheel every few months:

  • User registration
  • Email confirmation
  • Login
  • Logout

So, go get it now via the Google Code SVN repository. If you need help, read the wonderful documentation.

Special thanks to Laura Arguello for the crash-course on Mate, and Dan Wilson for writing the installation docs.

Welcome to my new site, again

I’ve finished moving everything over to WordPress now. I ditched the Flex site I was building because since I started it, I’ve decided to make my site less of a personal site and more of my portal to the Flex/AIR/CF community. Also, since I had started that site, I’ve started to focus on open-source projects, some my own, some that I contribute to.

I also have switched back to the design that everyone seemed to like so much. We’ll see how long this lasts, now that I have the vast library of WordPress templates at my fingertips.

I should have some neat announcements this month, so stay tuned.