Mixin: SC.Validatable

Views that include the Validatable mixin can be used with validators to ensure their values are valid.

Defined in: validatable.js

Field Summary

Class Methods

Field Detail

SC.Validatable.errorLabel String

This property must return the human readable name you want used when describing an error condition. For example, if set this property to "Your Email", then the returned error string might be something like "Your Email is not valid".

You can return a loc string here if you like. It will be localized when it is placed into the error string.

Default value:
null
SC.Validatable.isValid Boolean

YES if the receiver is currently valid.

This property watches the value property by default. You can override this property if you want to use some other method to calculate the current valid state.

Default value:
YES
SC.Validatable.ownerForm SC.View

The form that the view belongs to. May be null if the view does not belong to a form. This property is usually set automatically by an owner form view.

Default value:
null
SC.Validatable.validator SC.Validator

The validator for this field.

Set to a validator class or instance. If this points to a class, it will be instantiated when the validator is first used.

Default value:
null
SC.Validatable.validatorObject SC.Validator
Returns the validator object, if one has been created.

Class Method Detail

fieldValueForObject(object)

Convert the object into a field value.

This method will call the validator's fieldValueForObject if it exists.

Parameters:
object
{Object} the objec to convert
Returns:
Object
objectForFieldValue(fieldValue, partialChange)

Convert the field value string into an object.

This method will call the validators objectForFieldValue if it exists.

Parameters:
fieldValue Object
the raw value from the field.
partialChange Boolean
Returns:
Object
performValidate(partialChange)

Attempts to validate the receiver.

Runs the validator and returns SC.VALIDATE_OK, SC.VALIDATE_NO_CHANGE, or an error object. If no validator is installed, this method will always return SC.VALIDATE_OK.

Parameters:
partialChange Boolean
YES if this is a partial edit.
Returns:
String
SC.VALIDATE_OK, error, or SC.VALIDATE_NO_CHANGE
performValidateKeyDown(charStr)

Runs a keydown validation. Returns YES if the keydown should be allowed, NO otherwise. If no validator is defined, always returns YES.

Parameters:
charStr String
the key string
Returns:
Boolean
performValidateSubmit()

Runs validateSubmit. You should use this in your implementation of validateSubmit. If no validator is installed, this always returns SC.VALIDATE_OK

Returns:
String
validateSubmit()

Invoked by the owner form just before submission. Override with your own method to commit any final changes after you perform validation.

The default implementation simply calls performValidateSubmit() and returns that value.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)