Model Object
propertyIsBlank()
Signature
Section titled “Signature”propertyIsBlank() — returns boolean
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Returns true if the specified property doesn’t exist on the model or is an empty string.
This method is the inverse of propertyIsPresent().
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | yes | — | Name of property to inspect. |
Examples
Section titled “Examples”1. Basic usage
user = model("user").new();
isBlank = user.propertyIsBlank("firstName"); // returns true if firstName is not set
2. Property exists but is empty
user = model("user").new(firstName="");
isBlank = user.propertyIsBlank("firstName"); // true
3. Property exists with value
user = model("user").new(firstName="Joe");
isBlank = user.propertyIsBlank("firstName"); // false
4. Checking property that doesn’t exist on the model
isBlank = user.propertyIsBlank("nonexistentProperty"); // true
5. Using in validation logic
if (user.propertyIsBlank("email")) {
writeOutput("Email is required.");
}