Inherits from NSObject
Conforms to SFormTextFieldValidator
Declared in SFormTextFieldComparisonValidator.h
Availability
Related samples

Overview

A validator that compares the validating text field’s input against a specified text field’s input.

Tasks

  •   invalidMessage

    A string representing the invalid message to provide.

    property
  •   toCompare

    The text field that we are comparing the validating text field’s input against.

    property
  •   validResult

    The result needed from the comparison to achieve positive validation.

    property
  •   comparisonMode

    How to treat the value of the text field for the comparison.

    property
  • – initWithFieldToCompare:validResult:

    Returns an instance of this class that will compare the validating text field’s input against the input a provided text field.

Properties

comparisonMode

How to treat the value of the text field for the comparison.

@property (nonatomic, assign) SFormTextComparisonMode comparisonMode

Discussion

A value of SFormTextComparisonModeTextValue will compare the contents of the fields as NSStrings. A value of SFormTextComparisonModeNumberValue will compare the contents of the fields as NSNumbers. If either field’s values can not be converted successfully to an NSNumber, validation will return NO.

Declared In

SFormTextFieldComparisonValidator.h

invalidMessage

A string representing the invalid message to provide.

@property (nonatomic, strong) NSString *invalidMessage

Declared In

SFormTextFieldComparisonValidator.h

toCompare

The text field that we are comparing the validating text field’s input against.

@property (nonatomic, readonly, retain) SFormTextField *toCompare

Declared In

SFormTextFieldComparisonValidator.h

validResult

The result needed from the comparison to achieve positive validation.

@property (nonatomic, readonly, assign) SFormComparisonRule validResult

Declared In

SFormTextFieldComparisonValidator.h

Instance Methods

initWithFieldToCompare:validResult:

Returns an instance of this class that will compare the validating text field’s input against the input a provided text field.

- (instancetype)initWithFieldToCompare:(SFormTextField *)toCompare validResult:(SFormComparisonRule)validResult

Parameters

toCompare

The text field whose input will be compare with the validating text field’s input.

validResult

The comparison result that trigger provide positive validation.

Discussion

This validator calls the compare: method on the field’s value property, passing in the toCompare field’s value as the parameter. This validator will validate positively if the comparison result is the same as the valid result provided.

Declared In

SFormTextFieldComparisonValidator.h