From wiki.ginstr.com
Revision as of 20:58, 12 July 2017 by Mark (talk | contribs) (formatting)
Jump to: navigation, search

ComparatorValidator

Description
It performs a comparison of content between two widgets.
IMPORTANT: this validator is not executing required check, if value in widget is null it will return true. You should add RequiredValidator as well to this widget if you need value entered.

Attributes

Note: An attribute marked with asterisk (*) is obligatory
Attribute Description
message* Defines default message to be displayed when validation fails

Can be

  • @string
targetWidget Defines target that will get compared to widget holding the validator.

Validated widget and target have to be of same datatype in order to compare them successfully, with exception of equalLength comparator

comparator Defines which comparator to use when comparing two numeric values

Can be

pattern Defines regex pattern to be used with regex comparator type

Can be

  • source{n}, i.e. [pattern=@string/regex1,@+id/meter_counterDigits,@string/regex2]

Validator signatures

Compare values

[name:ComparatorValidator],[message=validatorMessage],[targetWidget=target],[comparator=comparatorType,[pattern=regexPattern]]

Example

@string/solarMeterEnterValues_currentMeterValueComparatorValidatorMessage - validator message
@+id/meter_counterDigits - target to compare
equalLength - comparator type
[name:ComparatorValidator],[message=@string/solarMeterEnterValues_currentMeterValueComparatorValidatorMessage], [targetWidget=@+id/meter_counterDigits], [comparator=equalLength]

Comparator types

comparator Description
empty (empty) Compares if value of validated widget is empty
notempty (notempty) Compares if value of validated widget is not empty
= (equals) Compares is content of validated widget and target is equal
! (not equal) Compares is content of validated widget and target is not equal
c= (case ignore equal) Compares is content of validated widget and target is equal and ignores case
c! (case ignore not equal) Compares is content of validated widget and target is not equal and ignores case
> (>, greater than) Compares if value of validated widget is greater than target value
>= (>=, greater than or equal) Compares if value of validated widget is greater than or equal to target value
&lt; (<, less than) Compares if value of validated widget is smaller than target value
&lt;= (<=, less than or equal) Compares if value of validated widget is less than or equal to target value
regex Compares if content of regex pattern stored in validator pattern matches the widget content
true (true) Compares if content of validated widget is "true"
false (false) Compares if content of validated widget is "false"
equalLength Compares if validated widget content length is equal to target value
equalLengthWidgets Compares if validated widget content length is equal to target value
equalLengthWidgetsIgnoreDecimalPart Is used together with equalLengthWidgets, allowed values true or false.

If enabled the equalLengthWidgets will ignore decimal part if a number is entered.