我想實現一個自定義的驗證器類。互聯網上有一些教程,例如http://blog.swwomm.com/2011/02/custom-grails-constraints.html在這些教程中描述,你必須在Config.groovy中註冊驗證類如何在Grails 3中註冊自定義的驗證器類
的問題是Config.groovy中通過的Grails 3. application.groovy我application.groovy看起來是這樣的替換:
import at.byte_code.businessSuite.core.NamespaceValidatorConstraint
import grails.validation.ConstrainedProperty
ConstrainedProperty.removeConstraint(ConstrainedProperty.VALIDATOR_CONSTRAINT)
ConstrainedProperty.registerNewConstraint(ConstrainedProperty.VALIDATOR_CONSTRAINT, NamespaceValidatorConstraint.class)
但是當我嘗試運行應用程序,我得到以下錯誤:
| Error Error occurred running Grails CLI: startup failed:
script1481056327870569414787.groovy: 1: unable to resolve class at.byte_code.businessSuite.core.NamespaceValidatorConstraint
@ line 1, column 1.
import at.byte_code.businessSuite.core.NamespaceValidatorConstraint
^
script1481056327870569414787.groovy: 2: unable to resolve class grails.validation.ConstrainedProperty
@ line 2, column 1.
import grails.validation.ConstrainedProperty
^
如何註冊我的自定義驗證程序類?
您可以鏈接任何描述此限制的文檔嗎? – Andreas
http://docs.grails.org/3.2.7/guide/upgrading.html - 段落GORM 6配置模型 – Mikhail