Model Class
validationTypeForProperty()
Signature
Section titled “Signature”validationTypeForProperty() — returns any
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Returns the validation type for the property.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | yes | — | Name of column to retrieve data for. |
Examples
Section titled “Examples”// 1. Get the validation type for a string column (e.g. firstName is varchar)
type = model("Employee").validationTypeForProperty("firstName");
// type -> "string"
// 2. Get the validation type for a numeric column (e.g. salary is integer)
type = model("Employee").validationTypeForProperty("salary");
// type -> "numeric"
// 3. Get the validation type for a date column (e.g. hireDate is a date/datetime column)
type = model("Employee").validationTypeForProperty("hireDate");
// type -> "date"
// 4. Property does not exist on the model — returns "string" as the default
type = model("Employee").validationTypeForProperty("nonExistentProperty");
// type -> "string"