@tillhub/schemas 6.465.0 → 6.465.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,16 @@ module.exports.request = {
9
9
  required: [
10
10
  'name'
11
11
  ],
12
- properties: base
12
+ properties: {
13
+ ...base,
14
+ name: {
15
+ type: 'string',
16
+ minLength: 1,
17
+ not: {
18
+ pattern: '^\\s|\\s$'
19
+ }
20
+ }
21
+ }
13
22
  }
14
23
 
15
24
  module.exports.response = {
@@ -7,7 +7,16 @@ module.exports.request = {
7
7
  additionalProperties: false,
8
8
  type: 'object',
9
9
  required: [],
10
- properties: base
10
+ properties: {
11
+ ...base,
12
+ name: {
13
+ type: 'string',
14
+ minLength: 1,
15
+ not: {
16
+ pattern: '^\\s|\\s$'
17
+ }
18
+ }
19
+ }
11
20
  }
12
21
 
13
22
  module.exports.response = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.465.0",
3
+ "version": "6.465.1",
4
4
  "private": false,
5
5
  "description": "All Tillhub API OpenAPI 3 compatible JSON Schemas.",
6
6
  "main": "./lib/index.js",
@@ -0,0 +1,42 @@
1
+ const test = require('tape')
2
+ const Ajv = require('ajv')
3
+ const validate = require('../helpers/validate-schema')
4
+ const tags = require('../../lib/v0/tags')
5
+
6
+ test('Tags: create schema validation', function (t) {
7
+ t.plan(2)
8
+ const createRequest = require('../../lib/v0/tags').create.request
9
+ const { valid, error } = validate(createRequest)
10
+ t.ok(valid, 'create schema is valid')
11
+ t.error(error, 'should not get any error')
12
+ t.end()
13
+ })
14
+
15
+ test('Tags: update schema validation', function (t) {
16
+ t.plan(2)
17
+ const updateRequest = require('../../lib/v0/tags').update.request
18
+ const { valid, error } = validate(updateRequest)
19
+ t.ok(valid, 'update schema is valid')
20
+ t.error(error, 'should not get any error')
21
+ t.end()
22
+ })
23
+
24
+ for (const operation of ['create', 'update']) {
25
+ test(`Tags: ${operation} rejects empty names and surrounding whitespace`, function (t) {
26
+ const validateRequest = new Ajv().compile(tags[operation].request)
27
+
28
+ for (const name of [
29
+ '', ' ', '\t\n', null, 42,
30
+ ' green', 'green ', ' green ',
31
+ '\tgreen', 'green\t', 'green\n', 'green\r\n',
32
+ '\u00a0green', 'green\u00a0', '\ufeffgreen', 'green\ufeff'
33
+ ]) {
34
+ t.notOk(validateRequest({ name }), `rejects name ${JSON.stringify(name)}`)
35
+ }
36
+ for (const name of ['g', 'green', 'Grüner Tee', 'Grüner Tee', '🟢']) {
37
+ t.ok(validateRequest({ name }), `accepts name ${JSON.stringify(name)}`)
38
+ }
39
+ t.equal(validateRequest({ deleted: true }), operation === 'update', 'only updates may omit the name')
40
+ t.end()
41
+ })
42
+ }
@@ -1,20 +0,0 @@
1
- const test = require('tape')
2
- const validate = require('../helpers/validate-schema')
3
-
4
- test('Tags: create schema validation', function (t) {
5
- t.plan(2)
6
- const createRequest = require('../../lib/v0/tags').create.request
7
- const { valid, error } = validate(createRequest)
8
- t.ok(valid, 'create schema is valid')
9
- t.error(error, 'should not get any error')
10
- t.end()
11
- })
12
-
13
- test('Tags: update schema validation', function (t) {
14
- t.plan(2)
15
- const updateRequest = require('../../lib/v0/tags').update.request
16
- const { valid, error } = validate(updateRequest)
17
- t.ok(valid, 'update schema is valid')
18
- t.error(error, 'should not get any error')
19
- t.end()
20
- })