User Guide
ComponentMixins.validateProperty() 231
Parameters
propertyName A string that contains the name of a property that belongs to
componentInstance.
Returns
An array, or null.
Description
Method; determines if the data in propertyName is valid based on the property’s schema
settings. The property’s schema settings are those specified on the Schema tab in the
Component inspector.
The method returns
null if the data is valid; otherwise, it returns an array of error messages
as strings.
Validation applies only to fields that have schema information available. If a field is an object
that contains other fields, each “child” field is validated, and so on, recursively. Each
individual field dispatches a
valid or invalid event, as necessary. For each data field
contained by
propertyName, this method dispatches valid or invalid events, as follows:
■ If the value of the field is null, and is not required, the method returns null. No events
are generated.
■ If the value the field is null, and is required, an error is returned and an invalid event
is generated.
■ If the value of the field is not null and the field’s schema does not have a validator, the
method returns
null; no events are generated.
■ If the value is not null and the field’s schema does define a validator, the data is processed
by the validator object. If the data is valid, a
valid event is generated and null is
returned; otherwise, an
invalid event is generated and an array of error strings
is returned.
Example
The following example shows how to use validateProperty() to make sure that text
entered by a user is of a valid length. You’ll determine the valid length by setting the
Validation Options for the String data type in the Component inspector’s Schema tab. If the
user enters a string of invalid length in the text field, the error messages returned by
validateProperty() are displayed in the Output panel.