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
- SC.Validatable.errorLabel
- SC.Validatable.isValid
- SC.Validatable.ownerForm
- SC.Validatable.validator
- SC.Validatable.validatorObject
Class Methods
- fieldValueForObject(object)
- objectForFieldValue(fieldValue, partialChange)
- performValidate(partialChange)
- performValidateKeyDown(charStr)
- performValidateSubmit()
- validateSubmit()
Field Detail
SC.Validatable.errorLabel StringThis 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
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
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
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
Class Method Detail
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
Convert the field value string into an object.
This method will call the validators objectForFieldValue
if it exists.
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.
Runs a keydown validation. Returns YES
if the keydown should be
allowed, NO otherwise. If no validator is defined, always returns YES.
Runs validateSubmit
. You should use this in your implementation of
validateSubmit
. If no validator is installed, this always returns
SC.VALIDATE_OK
- Returns:
- String
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.