Introducing A New Validation Framework, OK!

Today I released a new ColdFusion 9 ORM entity validation framework named OK!. This framework grew out of my attempt to use Hyrule in a large FW/1 Mura plugin. I really liked Hyrule, but I ran into a few issues with the framework and OK! is an attempt to address those issues.

OK! works very much like Hyrule, except it:

  • supports nested validation,
  • supports component level validation,
  • has better custom rule integration,
  • and supports all IsValid() validation rules including regular expressions.

Documentation is still a work in progress but there are plenty of examples of how to use the framework in the /tests directory. Please check it out and let me know what you think.

Comments
Jan's Gravatar Hi Nathan,

the framework looks really nice and I started playing around with it.
There is one general conceptual concern that I have. For type validation, isn't it already too late if it's done on the entity itself?

Pick the following example:
You have an integer/numeric property that you want to validate. If it's defined as type="numeric" on the property than this will crash if you try to use the setter method. The type validation of CF already took place. (same for dates, bit/boolean, etc.)
So does it make sense to validate types within the entity? I think that this needs to be done prior to setting the values on the entity. How can you work around this problem?
Or am I missing something?

Greetings from Germany,
Jan
# Posted By Jan | 12/21/11 5:55 AM
Marco Betschart's Gravatar Hi Nathan!

Sounds promising, I'll have a look at it!!
Nevertheless, here a few thoughts of mine about your decision of rolling your own validation framework and about hyrule:

In my personal opinion there are a few minor mistakes in the architecture of hyrule which prevent it to be fully enterprise ready. The type validation in combination of an notNull="true" which in some causes forces hyrule to throw an error if it hasn't a value is one thing. What's missing too is client side validation. Nevertheless, I think hyrule is a very simple but powerfull validation framework out there. Additionally Dan Vega is open for any proposals - so I don't understand why you have written your own validation framework "to address some issues" instead of do this in hyrule and send Dan the changes? Maybe I'm missing something?

I've played around to roll a stripped down hyrule - based on the idea of Sean Corfield's FW/1 and DI/1 - and had a discussion with Dan about it. Because I think hyrule is very clean and OOP-ish, but over factured for the job. My target is a single cfc with client side validation included based on the original idea of Dan. If you're interested in, I can send you a copy - so you can have a look at an early alpha stage?
# Posted By Marco Betschart | 12/22/11 4:57 AM
Nathan Mische's Gravatar Apologies for the delayed responses, I'm just returning from a long holiday vacation.

@Jan: You are correct. It seems that CF does built in type validation for entities, in which case you would need to handle those errors outside of the validate method. I may try to look into this further to see if there are any elegant ways to handle this situation.

@Marco: I considered forking Hyrule on github so I could submit my updates back to the project, but there appears to be a new version in the works and I was interested in staying close to the Hyrule 0.7 release as this is what I was going to be replacing in an existing app. Also I had some time constraints on this project that meant I needed to address the issues in Hyrule 0.7 quickly.

As for your project, while client side validation is nice, I'm not interested in implementing it at the moment and don't see it as a huge issue. Also, i'm not sure of the benifit of implementing this in one CFC? The ability to extend Hyrule with custom rules by implementing a simple CFC is a big win in my book.

For both Jan and Marco I will suggest that you investigate Validate This (http://www.validatethis.org/) to see if it better fits your use cases. It can generate client side validation and I don't think you need to populate your entities in order to do validation. Thanks for the feedback!
# Posted By Nathan Mische | 1/3/12 3:48 PM
Marco Betschart's Gravatar @Nathan:
Yeah you're right, there is a "new" version of hyrule out there on GitHub. But as you may have seen, the last update is more than a year ago. Because of this I've already contacted Dan Vega about his plans on his validation framework.

As you I've used hyrule on some projects too and every time I've used it, I hopped there will be an update for it soon to address issues like validation of non-required field types or context-based validation rules. But it never tend to happen till now.

I know validateThis too, but it was never really a choice for me. Since in my opinion it's not the way validation should happen these days in ColdFusion.

Because of these circumstance I can fully understand your choice of releasing another framework based on the idea of hyrule. But instead of creating different frameworks in my opinion the target should be an easy to use, "fully complete", robust and enterprise ready validation framework which is based on technology we use these days.

I think - and I'm quite sure you agree - hyrule is a good way to start to achieve this target. But what hyrule really needs is a community which takes the project to the next level and what makes me sad is to see, that there are developers out there which are willing to take the necessary effort (me too!), but there is no one which takes care of it :(

What would make me quite happy is to see ONE project - whether it's hyrule or Ok! - to put forward so the whole community gets involved or at least has the ability to use an easy to understand, enterprise ready and "complete" validation framework - instead of validateThis.

Please let me know what do you think about this idea.
# Posted By Marco Betschart | 2/28/12 9:50 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.