Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Client implements Bindable{
- static hasMany = [...]
- String cName
- String dName
- Date created
- static constraints = {
- cName unique:true, blank:false, maxSize:255
- dName unique:true, blank:false, maxSize:255
- }
- static mapping = {
- ....
- }
- String toString(){
- return cName
- }
- }
- trait Bindable {
- def bindFrom(source) {
- def thisz = this
- source.properties.each { key, value ->
- if (thisz.hasProperty(key) && !(key in ['class', 'metaClass'])){
- thisz[key] = value
- }
- }
- }
- }
- void "test cName cannot be blank"() {
- when:
- domain.cName = ""
- then:
- !domain.validate(['cName'])
- }
Add Comment
Please, Sign In to add comment