Joi validators that are shared across more than one service's tests. Validators which are only used by one service should be declared in that service's test file.
- Source:
Members
(inner, constant) isCommitHash :Joi.StringSchema
Validates a short or full git commit hash (7 to 40 hexadecimal characters).
Type:
- Joi.StringSchema
- Source:
(inner, constant) isComposerVersion :Joi.StringSchema
Simple regex for testing Composer version rules, e.g. 7.1, >=5.6,
>1.0 <2.0, !=1.0 <1.1 || >=1.2, 7.1.*, or 7.* || 5.6.*.
This regex does not support branches, minimum-stability, ref, or any (*).
Type:
- Joi.StringSchema
- Source:
- See:
(inner, constant) isCurrency :Joi.StringSchema
Validates a currency amount string with an optional $ prefix, thousands
separators, and up to two decimal places. For example, $1,530,602.24 and
1,530,602.24 are valid, while $1,666.24$, ,1,666,88,, 1.6.66,6, and
.1555. are not.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isCustomCompactTestTotals :Joi.StringSchema
Validates a custom compact test totals string with the emoji labels
๐, ๐คฆโโ๏ธ, and ๐คท, e.g. ๐ 5 | ๐คฆโโ๏ธ 1 | ๐คท 2.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isCustomTestTotals :Joi.StringSchema
Validates a custom test totals string with the labels good, bad, and
n/a, e.g. 5 good, 1 bad, 2 n/a.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isDecimalPercentage :Joi.StringSchema
Validates a non-negative decimal percentage, e.g. 0.5% or 12.34%.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isDecimalPercentageNegative :Joi.StringSchema
Same as isDecimalPercentage, but also accepts negative values, e.g. -0.5%.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isDefaultCompactTestTotals :Joi.StringSchema
Validates a default compact test totals string with the glyph labels
โ, โ, and โ, e.g. โ 5 | โ 1 | โ 2.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isDefaultTestTotals :Joi.StringSchema
Validates a default test totals string with the labels passed, failed,
and skipped, e.g. 5 passed, 1 failed, 2 skipped.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isDependencyState :Joi.StringSchema
Validates a dependency state string, e.g. up to date, 3 out of date,
or 2 deprecated.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isFormattedDate :Joi.AlternativesSchema
Validates a human-readable formatted date, such as today, yesterday,
last tuesday, or january 2021.
Type:
- Joi.AlternativesSchema
- Source:
(inner, constant) isHumanized :Joi.StringSchema
Validates a humanized duration string, e.g. 3 days, 1 hour, or 2 years.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isIecFileSize :Joi.StringSchema
Validates an IEC (binary) file size, e.g. 1 B, 12.5 KiB, or 2 MiB.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isIntegerPercentage :Joi.StringSchema
Validates a non-negative integer percentage, e.g. 0%, 75%, or 100%.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isIntegerPercentageNegative :Joi.StringSchema
Same as isIntegerPercentage, but also accepts negative values, e.g. -25%.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetric :Joi.StringSchema
Validates a metric-formatted positive number, e.g. 10, 1k, or 2.5M.
Required to be > 0, because accepting zero masks many problems.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetricAllowNegative :Joi.StringSchema
Same as isMetric, but also accepts zero and negative numbers,
e.g. 0, -1k, or -2.5M.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetricClosedIssues :Joi.StringSchema
Validates a metric followed by closed, e.g. 3 closed or 1.2k closed.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetricFileSize :Joi.StringSchema
Validates a metric (SI) file size, e.g. 1 B, 12.5 kB, or 2 MB.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetricOpenIssues :Joi.StringSchema
Validates a metric followed by open, e.g. 3 open or 1.2k open.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetricOverMetric :Joi.StringSchema
Validates a metric followed by / and another metric, e.g. 3/10 or 1.2k/5k.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isMetricOverTimePeriod :Joi.StringSchema
Validates a metric followed by / and a time period, e.g. 3/day or 1.2k/month.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isOrdinalNumber :Joi.StringSchema
Validates an ordinal number string with a superscript suffix, e.g. 1หขแต, 2โฟแต, or 11แตสฐ.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isOrdinalNumberDaily :Joi.StringSchema
Same as isOrdinalNumber, but followed by daily, e.g. 1หขแต daily.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isPercentage :Joi.AlternativesSchema
Validates any percentage string by combining isIntegerPercentage, isDecimalPercentage, isIntegerPercentageNegative, and isDecimalPercentageNegative.
Type:
- Joi.AlternativesSchema
- Source:
(inner, constant) isPhpVersionReduction :Joi.StringSchema
Validates the reduced PHP version string produced by
php-version.versionReduction(), e.g. >= 7, >= 7.1,
5.4, 5.6, 7.2, or 5.4 - 7.1, HHVM.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isRelativeFormattedDate :Joi.AlternativesSchema
Validates a relative formatted date, e.g. 2 days ago, in 3 months,
or a few seconds ago.
Type:
- Joi.AlternativesSchema
- Source:
(inner, constant) isStarRating :Joi.StringSchema
Validates a 5-character star rating string composed of full, fractional,
and empty star glyphs, e.g. โ
โ
โ
ยพโ.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isVPlusDottedVersionAtLeastOne :Joi.StringSchema
Validates a version string prefixed by v with at least a major version
and optional minor and patch numbers, e.g. v1, v1.2, or v1.2.3.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isVPlusDottedVersionNClauses :Joi.StringSchema
Validates a version number prefixed by v with N 'clauses',
e.g. v1.2 or v1.22.7.392.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isVPlusDottedVersionNClausesWithOptionalSuffix :Joi.StringSchema
Validates a version number prefixed by v with N 'clauses' and an
optional text suffix, e.g. -beta, -preview1, -release-candidate,
+beta, or ~pre9-12.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isVPlusDottedVersionNClausesWithOptionalSuffixAndEpoch :Joi.StringSchema
Same as isVPlusDottedVersionNClausesWithOptionalSuffix, but also
accepts an optional 'epoch' prefix that can be found e.g. in distro
package versions, like 4:6.3.0-4.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isVPlusTripleDottedVersion :Joi.StringSchema
Validates a version string with three dotted numeric clauses prefixed
by v, e.g. v1.2.3.
Type:
- Joi.StringSchema
- Source:
(inner, constant) isZeroOverTimePeriod :Joi.StringSchema
Validates a literal zero followed by / and a time period, e.g. 0/day or 0/year.
Type:
- Joi.StringSchema
- Source:
Methods
(inner) isMetricWithPattern(nestedRegexp) → {Joi.StringSchema}
Creates a validator that matches a metric (see isMetric) followed
by another pattern, e.g. open or /year.
Parameters:
| Name | Type | Description |
|---|---|---|
nestedRegexp |
RegExp | Pattern that must appear after the metric |
- Source:
Returns:
Joi string schema for the combined pattern
- Type
- Joi.StringSchema
(inner) makeCompactTestTotalsValidator(labels) → {Joi.StringSchema}
Creates a validator for test totals in the compact format
<passed> <n>( | <failed> <n>)?( | <skipped> <n>)?, e.g. โ 5 | โ 1.
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
labels |
object | Label strings used for each outcome Properties
|
- Source:
Returns:
Joi string schema for the compact test totals format
- Type
- Joi.StringSchema
(inner) makeTestTotalsValidator(labels) → {Joi.StringSchema}
Creates a validator for test totals in the format
<n> <passed>(, <n> <failed>)?(, <n> <skipped>)?, e.g. 5 passed, 1 failed.
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
labels |
object | Label strings used for each outcome Properties
|
- Source:
Returns:
Joi string schema for the test totals format
- Type
- Joi.StringSchema
(inner) withRegex(re) → {Joi.StringSchema}
Creates a Joi string validator that matches the given regular expression.
Parameters:
| Name | Type | Description |
|---|---|---|
re |
RegExp | Regular expression the string must match |
- Source:
Returns:
Joi string schema validating against the regex
- Type
- Joi.StringSchema