Skip to content

feat(variable): add StringVariable operators #33

@gregswindle

Description

@gregswindle

briefcase 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 a StringVariable.prototype.value ends with the characters of a specified StringVariable.prototype.value.
  • 2. hasMaxLength determines whether a single StringVariable.prototype.value is less than or equal to a specific character count (i.e., a NumberVariable.prototype.value).
  • 3. hasMinLength determines whether a single StringVariable.prototype.value is greater than or equal to a specific character count (i.e., a NumberVariable.prototype.value).
  • 4. isEmpty determines whether a single StringVariable.prototype.value has zero (0) characters (represented as a NumberVariable).
  • 5. isNotEmpty determines whether a single StringVariable.prototype.value has more than (0) characters (i.e., a NumberVariable.prototype.value of 0).
  • 6. isOneOf evaluates whether a StringVariable.prototype.value is an element in an ArrayVariable.prototype.value.
  • 7. includes determines whether one StringVariable.prototype.value may be found within another StringVariable.prototype.value.
  • 8. matches retrieves the result of matching a StringVariable.prototype.value against a regular expression.
  • 9. startsWith determines whether a StringVariable.prototype.value ends with the characters of another StringVariable.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 external ow external module.

Sorhus, Sindre. (2019) StringPredicate | ow. Retrieved May 18, 2019, from https://sindresorhus.com/ow/classes/stringpredicate.html

Metadata

Metadata

Assignees

Labels

priority: mediumWill add consumer value when released.type: docsAdd, edit, or delete instructional material.type: featureValuable new or enhanced functionality. ⇧ Bumps the MINOR semver.type: testAdding, correcting, or improving tests (coverage).

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions