Quantcast

length vs. size in constaints

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

length vs. size in constaints

Dierk König
Hi,

in constraints, we have

length
minLength
maxLength

size
minSize
maxSize

min
max
range

I understand min/max/range work on the value
while all the others work on the cardinality.

However, I think we could consolidate the length
and size variants into using only the size ones,
duck typing on 'size()-able' so to speak.

-> easier to remember.

Mittie

P.S. How about using the Groovy classifier
mechanism isCase()?

foo(case: ~/.../)
foo(case: {it > 10} )
foo(case: [1,2,3] )

just an idea. Probably not helpful for creating
DB constraints (is Grails doing that?).

cheers
Mittie






Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: length vs. size in constaints

graemer
On 10/03/06, Dierk Koenig <[hidden email]> wrote:

> Hi,
>
> in constraints, we have
>
> length
> minLength
> maxLength
>
> size
> minSize
> maxSize
>
> min
> max
> range
Yeh I decided to have all these as they make sense for different
types, size doesn't in my opinion make sense for a string. And 'range'
makes more sense when you're talking about dates or numbers.

Internally they actually use the same code

>
> I understand min/max/range work on the value
> while all the others work on the cardinality.
>
> However, I think we could consolidate the length
> and size variants into using only the size ones,
> duck typing on 'size()-able' so to speak.
Maybe.

>
> -> easier to remember.
>
> Mittie
>
> P.S. How about using the Groovy classifier
> mechanism isCase()?
>
> foo(case: ~/.../)
> foo(case: {it > 10} )
> foo(case: [1,2,3] )
Great idea! How do i access this from java though?

>
> just an idea. Probably not helpful for creating
> DB constraints (is Grails doing that?).
No not at the moment, its auto generating the database, but just using
what Hibernate defaults to for different types. It is assumed that in
the real world one would actually create the database with a SQL
script or such like rather than auto-generating it.

Also for 0.2 we plan to use GSQL to make a db easier to define

Graeme

>
> cheers
> Mittie
>
>
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: length vs. size in constaints

Dierk König
> > in constraints, we have
...
> Internally they actually use the same code

Ok, I think it's fine then since the user has the coice.

> > foo(case: ~/.../)
> > foo(case: {it > 10} )
> > foo(case: [1,2,3] )
> Great idea! How do i access this from java though?

 value.invokeMethod("isCase", foo)
I'd guess.

cheers
Mittie
Loading...