2015-11-12 33 views
0

我有這個類:grails - 最小/最大約束失敗浮動?

class SomeClass { 

    float percent 

    static constraints = { 
     percent(min:1.0F, max:100.0F) 
    } 
} 

當我啓動應用程序,我得到的錯誤:

Parameter for constraint [min] of property [percent] of class [class SomeClass] must be the same type as property: [float] 

這是bug還是我究竟做錯了什麼?

回答

0

,我認爲你應該使用小f代替F

static constraints = { 
    percent(min:1.0f, max:100.0f) 
} 

嘗試改變的percentFloat類型,然後1.0F應該是有效的

+0

這是我首先嚐試。這有同樣的結果。我在大文字F的文檔中找到了一個例子 - 這就是爲什麼我這樣寫它的原因 – Bernhard

+0

嘗試將'percent'的類型改爲'Float',然後'1.0F'應該是有效的 – injecteer