Skip to content

Model Class

validationTypeForProperty()

validationTypeForProperty() — returns any

Available in: model Category: Miscellaneous Functions

Returns the validation type for the property.

NameTypeRequiredDefaultDescription
propertystringyes—Name of column to retrieve data for.
// 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"