Model Object
valid()
Signature
Section titled “Signature”valid() — returns boolean
Available in: model
Category: Error Functions
Description
Section titled “Description”Runs the validation on the object and returns true if it passes it.
CFWheels will run the validation process automatically whenever an object is saved to the database, but sometimes it’s useful to be able to run this method to see if the object is valid without saving it to the database.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
callbacks | boolean | no | true | Set to false to disable callbacks for this method. |
validateAssociations | boolean | no | false |
Examples
Section titled “Examples”// Check if a user is valid before proceeding with execution
user = model("user").new(params.user);
if user.valid(){
// Do something here
}