Model Class
validationTypeForProperty()
Signature
Section titled “Signature”validationTypeForProperty() — returns any
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Returns the type of validation that Wheels would apply for a given property. This is useful if you want to dynamically inspect a model’s property type or apply logic based on the property’s expected format.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | yes | — | Name of column to retrieve data for. |
Examples
Section titled “Examples”// Create a new employee object
employee = model("employee").new();
1. Assume 'firstName' is a varchar(50) column
employee.validationTypeForProperty("firstName") (This will output: "string")
2. Assume 'hireDate' is a datetime column
employee.validationTypeForProperty("hireDate") (This will output: "date")
3. Assume 'salary' is a numeric column
employee.validationTypeForProperty("salary") (This will output: "numeric")