Contacts.cfc
Let's use CommandBox to build it:
1
coldbox create orm-entity entityName=contacts primaryKey=contactID properties=firstName,lastName,email --open
Copied!
Then spice it up with the validation constraints
1
/**
2
* A cool Contact entity
3
*/
4
component persistent="true" table="contacts"{
5
6
// Primary Key
7
property name="contactID" fieldtype="id" column="contactID" generator="native" setter="false";
8
9
// Properties
10
property name="firstName" ormtype="string";
11
property name="lastName" ormtype="string";
12
property name="email" ormtype="string";
13
14
// validation
15
this.constraints = {
16
firstName = {required=true},
17
lastName = {required=true},
18
email = {required=true, type="email"}
19
};
20
21
}
Copied!
Last modified 3yr ago
Copy link
Edit on GitHub