Beginning Groovy, Grails and Griffon by Vishal Layka & Christopher M. Judd & Joseph Faisal Nusairat & Jim Shingler
Author:Vishal Layka & Christopher M. Judd & Joseph Faisal Nusairat & Jim Shingler
Language: eng
Format: epub
ISBN: 9781430248064
Publisher: Apress
Of course, it is impossible for the Grails team to predict all the possible constraints needed by an application. Using pre-created constraints is the easy part. In the next section, we’ll show you how to create your own customized constraints using closures.
Creating Custom Constraints
Let’s take another look at that Todo object and what other constraints you need to define for it. Let’s examine the startDate property and see what you need to constrain on it. For starters, you don’t want to allow users to use start dates in the past. The purpose of this application is to create tasks that start now or in the future; in theory, this is something that is probably created at the beginning and never changed. Nothing in the built-in constraints shown in Table 6-2 does what you need, so you need to create your first custom constraint. You need to allow the constraint to be null, and if the constraint is filled in, you need to make sure the date doesn’t occur in the past.
To define custom constraints in GORM, mark the custom constraint with a validator. Take a look at this in action in Listing 6-20.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12585)
Hello! Python by Anthony Briggs(9921)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9799)
The Mikado Method by Ola Ellnestam Daniel Brolund(9782)
Dependency Injection in .NET by Mark Seemann(9345)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8305)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7769)
Grails in Action by Glen Smith Peter Ledbrook(7700)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7563)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7128)
Microservices with Go by Alexander Shuiskov(6890)
Practical Design Patterns for Java Developers by Miroslav Wengner(6805)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6749)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6421)
Angular Projects - Third Edition by Aristeidis Bampakos(6163)
The Art of Crafting User Stories by The Art of Crafting User Stories(5688)
NetSuite for Consultants - Second Edition by Peter Ries(5616)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5427)
Kotlin in Action by Dmitry Jemerov(5070)
