Files
shields/services/validators.js
chris48s c762d971b4 upgrade Joi and related packages (#4060)
* 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
2019-09-23 17:36:56 +01:00

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'] }),
}