• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

badges / shields / 12851394349

18 Jan 2025 07:16PM UTC coverage: 91.115% (-1.4%) from 92.488%
12851394349

push

github

web-flow
fix badge-maker package tests (#10809)

6572 of 6836 branches covered (96.14%)

8 of 8 new or added lines in 3 files covered. (100.0%)

48 existing lines in 11 files now uncovered.

49254 of 54057 relevant lines covered (91.11%)

113.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.42
/services/validators.js
1
/**
4✔
2
 * This module contains commonly used validators.
4✔
3
 *
4✔
4
 * @module
4✔
5
 */
4✔
6

4✔
7
import {
4✔
8
  semver as joiSemver,
4✔
9
  semverRange as joiSemverRange,
4✔
10
} from 'joi-extension-semver'
4✔
11
import joi from 'joi'
4✔
12
const Joi = joi.extend(joiSemver).extend(joiSemverRange)
4✔
13

4✔
14
/**
4✔
15
 * Joi validator that checks if a value is a number, an integer, and greater than or equal to zero.
4✔
16
 *
4✔
17
 * @type {Joi}
4✔
18
 */
4✔
19
const optionalNonNegativeInteger = Joi.number().integer().min(0)
4✔
20

4✔
21
export { optionalNonNegativeInteger }
4✔
22

4✔
23
/**
4✔
24
 * Joi validator that checks if a value is a number, an integer, greater than or equal to zero and the value must be present.
4✔
25
 *
4✔
26
 * @type {Joi}
4✔
27
 */
×
28
export const nonNegativeInteger = optionalNonNegativeInteger.required()
4✔
29

4✔
30
/**
4✔
31
 * Joi validator that checks if a value is a number, an integer and the value must be present.
4✔
32
 *
4✔
33
 * @type {Joi}
4✔
34
 */
4✔
35
export const anyInteger = Joi.number().integer().required()
4✔
36

4✔
37
/**
4✔
38
 * Joi validator that checks if a value is a valid semantic versioning string and the value must be present.
4✔
39
 *
4✔
40
 * @type {Joi}
4✔
41
 */
4✔
42
export const semver = Joi.semver().valid().required()
4✔
43

4✔
44
/**
4✔
45
 * Joi validator that checks if a value is a valid semantic versioning range and the value must be present.
4✔
46
 *
×
47
 * @type {Joi}
×
48
 */
×
49
export const semverRange = Joi.semverRange().valid().required()
4✔
50

4✔
51
/**
4✔
52
 * Joi validator that checks if a value is a string that matches a regular expression.
4✔
53
 * The regular expression matches strings that start with one or more digits, followed by zero or more groups of a dot and one or more digits,
4✔
54
 * followed by an optional suffix that starts with a dash or a plus sign and can contain any characters.
4✔
55
 * This validator can be used to validate properties that can be version strings with an optional suffix or absent.
4✔
56
 * For example, some valid values for this validator are: 1, 1.0, 1.0.0, 1.0.0-beta
4✔
57
 * Some invalid values for this validator are: abc, 1.a, 1.0-, .1
4✔
58
 *
4✔
59
 * @type {Joi}
4✔
60
 */
4✔
61
export const optionalDottedVersionNClausesWithOptionalSuffix =
4✔
62
  Joi.string().regex(/^\d+(\.\d+)*([-+].*)?$/)
×
63

×
64
/**
×
65
 * Joi validator that checks if a value is a URL
4✔
66
 *
4✔
67
 * TODO: This accepts URLs with query strings and fragments, which for some purposes should be rejected.
4✔
68
 *
4✔
69
 * @type {Joi}
4✔
70
 */
4✔
71
export const optionalUrl = Joi.string().uri({ scheme: ['http', 'https'] })
4✔
72

4✔
73
/**
4✔
74
 * Joi validator that checks if a value is a URL and the value must be present.
4✔
75
 *
4✔
76
 * @type {Joi}
4✔
UNCOV
77
 */
×
78
export const url = optionalUrl.required()
4✔
79

4✔
80
/**
4✔
81
 * Joi validator for a file size we are going to pass to bytes.parse
4✔
82
 * see https://github.com/visionmedia/bytes.js#bytesparsestringnumber-value-numbernull
4✔
83
 *
4✔
84
 * @type {Joi}
4✔
85
 */
4✔
86
export const fileSize = Joi.string()
4✔
87
  .regex(/^[0-9]+(b|kb|mb|gb|tb)$/i)
4✔
UNCOV
88
  .required()
×
UNCOV
89

×
UNCOV
90
/**
×
91
 * Joi validator that checks if a value is a relative-only URI
4✔
92
 *
4✔
93
 * @type {Joi}
4✔
94
 */
4✔
95
export const relativeUri = Joi.string().uri({ relativeOnly: true })
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc