Skip to content

Model Configuration

afterValidationOnCreate()

afterValidationOnCreate() — returns void

Available in: model Category: Callback Functions

Registers method(s) that should be called after a new object is validated.

NameTypeRequiredDefaultDescription
methodsstringno—Method name or list of method names that should be called when this callback event occurs in an object’s life cycle (can also be called with the method argument).
// 1. Call a single method after a new object is validated on create
component extends="Model" {
	function config() {
		afterValidationOnCreate("assignDefaults");
	}

	private function assignDefaults() {
		if (!Len(this.role)) {
			this.role = "member";
		}
	}
}

// 2. Call multiple methods after validation on create (comma-delimited list)
component extends="Model" {
	function config() {
		afterValidationOnCreate("sanitizeFields,logNewRecord");
	}
}

// 3. Use the singular `method` alias for clarity
component extends="Model" {
	function config() {
		afterValidationOnCreate(method="trimWhitespace");
	}
}