gorm


Domain class auto validation in grails


I am fetching list of results from database but the list doesn't validates the constraints until i call "validate()" method for each objects.
def temp = ConfigInfo.where { projectId == project }.findAll()
//at this stage domain class is not validated
temp.each {
println "validate" + it.validate()
println "has error" + it.hasErrors()
}
//in the above code block validate() is called, I don't want to do this.
// is it possible to configure it happen automatically and i get the validated objects.
I don't want to invoke validate method.
is there any way or configuration in grails such that domain class get validated automatically.
Please help me in this.
Grails domain class objects get validated before save.
Use the following in your domain model to set the validation rules:
static constraints = {
// whatever you want to validate
}
Whenever you save an object it will be validated by the constraints you set. When the object is persistent in the database it has always been validated.
All you need to do is that just define all your validation in constraints closure.
e.g.
static constraints = {
id maxLength: 5
//etc...
}
at the time of saving object you just need to check object is validate or not!, it will return true/false.
look this: click here

Related Links

GORM findAll + cannot pass dynamic List as named parameter
How to display database records in grails
Configure Grails 3.0.9 for Oracle 12c with identity PK?
Adding condition to findAll and findAllBy methods
Neo4j and Mongodb as datasource in Grails
GORM (varchar .save(), non DATE): ORA-01861: literal does not match format string
GORM addTo methods not found in Spock test
spring-boot property exception while externalizing datasource properties and using actuator
Mapping hasMany relation and saving the related data
Method on class [] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails Correctly
What happens when two app servers in cluster start LiquiBase update (via Grails)?
use of mappedBy in Many to Many relationship in Grails
Domain class auto validation in grails
Grails Detached Criteria Query and “group by” and “having” clause
Script for saving large no of entries in mongodb
Does the multiple datasource feature of Grails 2.0 support relations?

Categories

HOME
wso2
gerrit
omnet++
c#-4.0
push-notification
alfresco
getelementsbytagname
graphql
cakephp-2.5
disassembler
mvvmcross
fancybox
azure-media-services
uber-api
add
adfs
dax
quicklook
resize
hex-editors
ups
jsprit
iolanguage
openrefine
windows-7-x64
http-status-code-504
crystal-reports-2008
visual-composer
swingx
grails3
excel-2007
mmap
zurb-foundation-6
buildbot
status
info.plist
linkerd
maquette
xacml
wtx
objectanimator
gsmcomm
google-rich-snippets
kendo-ui-grid
android-nestedscrollview
geopositioning
google-api-nodejs-client
normal-distribution
hexo
main
espeak
sharefile
c11
uft-api
splice
azure-ml
preconditions
galen
fedex
core-plot
powershell-dsc
nxlog
node-sass
drupal-6
knockout-components
crypt
sqlbulkcopy
color-profile
measures
django-debug-toolbar
autorest
fuzzy-search
qgraphicsview
make-install
dataview
itextpdf
xpath-1.0
kendonumerictextbox
reactive-banana
deis
sniffer
unity3d-gui
ami
remobjects
dundas
notify
csquery
markers
rdl
valueconverter
xceed-datagrid
typo3-neos
imdbpy
listings
blending
dbconnection
easy-install
eventlistener
jelly
distutils
gil
nsnetservice
funscript
twrequest
heartbeat
celltable
fixed-width
zend-tool
nerddinner

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App