feat(variable): add StringVariable operators
gregswindle opened this issue · 0 comments
gregswindle commented
Feature Request
1. User story
As a rule-base administrator,
I want to more operator options for StringVariables
In order to create and maintain succinct Rules
and RuleSets
.
2. Acceptance criteria
We'll be done when StringVariable
provides these methods:
- 1.
endsWith
determines whether aStringVariable.prototype.value
ends with the characters of a specifiedStringVariable.prototype.value
. - 2.
hasMaxLength
determines whether a singleStringVariable.prototype.value
is less than or equal to a specific character count (i.e., aNumberVariable.prototype.value
). - 3.
hasMinLength
determines whether a singleStringVariable.prototype.value
is greater than or equal to a specific character count (i.e., aNumberVariable.prototype.value
). - 4.
isEmpty
determines whether a singleStringVariable.prototype.value
has zero (0) characters (represented as aNumberVariable
). - 5.
isNotEmpty
determines whether a singleStringVariable.prototype.value
has more than (0) characters (i.e., aNumberVariable.prototype.value
of 0). - 6.
isOneOf
evaluates whether aStringVariable.prototype.value
is an element in anArrayVariable.prototype.value
. - 7.
includes
determines whether oneStringVariable.prototype.value
may be found within anotherStringVariable.prototype.value
. - 8.
matches
retrieves the result of matching aStringVariable.prototype.value
against a regular expression. - 9.
startsWith
determines whether aStringVariable.prototype.value
ends with the characters of anotherStringVariable.prototype.value
.
3. Notes
- As with all operators, these methods return a
Proposition
. - All methods include argument type checks, and will thrown an
ArgumentError
whenever given an unexpected type.
4. Attributions
These methods were inspired by Sindre Sorhus's ow
module.
Sorhus, Sindre. (2019) StringPredicate | ow. Retrieved May 18, 2019, from https://sindresorhus.com/ow/classes/stringpredicate.html