Parent/child relation is giving weird duplicate error on validation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Parent/child relation is giving weird duplicate error on validation

Marcel Overdijk
This post was updated on .
I basically have 4 domain classes:

Customer
Product
Receipt (containing Customer ref, date and receipt lines)
ReceiptLine (containing Product ref, amount, vat percentage, quantity)

When I have a map like:

def params = [
    'customer.id': customerInstance.id,
    'receiptDate': new Date(),
    'lines[0].product.id': productInstance.id,
    'lines[0].grossAmount': 0.8,
    'lines[0].quantity': 1,
]

// note that required vat percentage field is omitted!!

I can do:

def receiptInstance = new Receipt(params)

which also works. Then validating it:

if (!receiptInstance.validate()) {
    receiptInstance.errors.each {
        println it
    }
}

And of course Grails reports the error as we are missing the required vat percentage field.

The problem is 2 errors are reported:

grails.validation.ValidationErrors: 2 errors
Field error in object 'Receipt' on field 'lines[0][1].vatPercentage'
Field error in object 'Receipt' on field 'lines[0].vatPercentage'

The last one I expected... but where is the first one coming from. Why lines[0][1] ? I really cannot explain...




Reply | Threaded
Open this post in threaded view
|

Re: Parent/child relation is giving weird duplicate error on validation

Marcel Overdijk
I tried a similar setup using plain Spring MVC.
In that scenario I didn't had the 'duplicate' error codes.

There I only have the [0] error code, and not the [0][1] one.

I just wanted to rule that is was Spring validation causing this.

Any ideas what Grails is doing differently here?
Reply | Threaded
Open this post in threaded view
|

Re: Parent/child relation is giving weird duplicate error on validation

emiles
Duplicate validation errors are supposed to be fixed in version 2.1.1.  Implementation-wise, the errors are stack-based with no duplication checks.  Very annoying when it gets to the view and duplicate messages are displayed.
Reply | Threaded
Open this post in threaded view
|

Re: Parent/child relation is giving weird duplicate error on validation

Marcel Overdijk
Yes I can confirm this is solved in 2.1.1.

Sent from my iPhone

On 16 okt. 2012, at 21:42, "emiles [via Grails]" <[hidden email]> wrote:

Duplicate validation errors are supposed to be fixed in version 2.1.1.  Implementation-wise, the errors are stack-based with no duplication checks.  Very annoying when it gets to the view and duplicate messages are displayed.


To unsubscribe from Parent/child relation is giving weird duplicate error on validation, click here.
NAML