Skip to content

Model Object

propertyIsBlank()

propertyIsBlank() — returns boolean

Available in: model Category: Miscellaneous Functions

Returns true if the specified property doesn’t exist on the model or is an empty string. This method is the inverse of propertyIsPresent().

NameTypeRequiredDefaultDescription
propertystringyesName of property to inspect.
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.");
}