* update dependencies * (core) children --> keys * (core) fix/update BaseService validate * (core) update error messages in tests * (core) only Joi.attempt if we've got a Joi schema * (core) allow 'expected' to be a regex * (services) pass 2 schema to .alternatives() * (services) functions --> Joi schema * (services) update expected error message * (services) explicit check for color: undefined * re-bump joi * (services) wrap another regex * (core/services) remove use of array arguments * (core/services) when --> conditional * (services) remove more array arguments * fix spelling in var name * DRY up sonar helper
37 lines
798 B
JavaScript
37 lines
798 B
JavaScript
'use strict'
|
|
|
|
const { semver, semverRange } = require('joi-extension-semver')
|
|
const Joi = require('@hapi/joi')
|
|
.extend(semver)
|
|
.extend(semverRange)
|
|
|
|
const optionalNonNegativeInteger = Joi.number()
|
|
.integer()
|
|
.min(0)
|
|
|
|
module.exports = {
|
|
optionalNonNegativeInteger,
|
|
|
|
nonNegativeInteger: optionalNonNegativeInteger.required(),
|
|
|
|
anyInteger: Joi.number()
|
|
.integer()
|
|
.required(),
|
|
|
|
semver: Joi.semver()
|
|
.valid()
|
|
.required(),
|
|
|
|
semverRange: Joi.semverRange()
|
|
.valid()
|
|
.required(),
|
|
|
|
optionalDottedVersionNClausesWithOptionalSuffix: Joi.string().regex(
|
|
/^\d+(\.\d+)*([-+].*)?$/
|
|
),
|
|
|
|
// TODO This accepts URLs with query strings and fragments, which for some
|
|
// purposes should be rejected.
|
|
optionalUrl: Joi.string().uri({ scheme: ['http', 'https'] }),
|
|
}
|