teamcfadvance / ValidateThis

An object oriented validation framework for ColdFusion objects
http://www.validatethis.org
44 stars 32 forks source link

Updated the Min & Max length defaults to 0. #66

Closed gregmoser closed 12 years ago

gregmoser commented 12 years ago

I'm not sure why the default min & max length for the collectionSize validation method was set to 1. It seems to me that it makes more sense to have the validation start at 0. I have a requirement to have my validation start at min 0 and max 0 so It seems like it makes sense to have the rule look like this:

<property name="products">
    <rule type="collectionSize" context="delete">
        <param name="max" value="0" />
    </rule>
</property>

This rule is for our "Product Type" orm entity in an eCommerce application. Before we delete, I want to make sure that the one-to-many relationship of products is an empty array so that I don't leave any products out there without a product type.

I hope that this example makes sense.

-Greg

gregmoser commented 12 years ago

Actually ignore this pull request... there are a lot of other aspects of this server validator that need to be changed, and I also need to update the client validator to work.

But i am interested to hear feedback on what you think of this conceptually.

-Greg

bobsilverberg commented 12 years ago

I was just going to respond to the first pull request that there is other work to be done. I wrote a failing test case based on your earlier report and am just waiting to hear back from Adam who originally wrote the components. I will take a look at your suggested fixes, though, as it does need to be fixed,

gregmoser commented 12 years ago

Ya, this was one of those last minute walking out of the office things... But at the very least I wanted to open up the dialog about making the default min & max 0 instead of 1 because to me that just makes sense. I'm happy to refactor and fully test the componet for each data type as long as we are on the same page with how it "should" work.

At the end of the day, I really like the Idea of using ValidateThis to determine if ORM entities can be deleted, and collectionSize is a crucial rule component for making that work.

-Greg

bobsilverberg commented 12 years ago

Can you bring this up on the ValidateThis-dev Google group for discussion? That way other interested parties can be involved.

Thanks.

gregmoser commented 12 years ago

Will do, thanks.