Skip to content

Commit 6860baf

Browse files
Add format as valid child to fields (#62)
* chore: add format as valid child to fields * use regex format for text input format schema * add test for text field format * use json schema draft 7 --------- Co-authored-by: Angus Fretwell <angusfretwell@me.com>
1 parent 8bb8cd2 commit 6860baf

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

schema.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "JSON schema for Buildkite pipeline configuration files",
3-
"$schema": "http://json-schema.org/draft-06/schema#",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
44
"fileMatch": [
55
"buildkite.yml",
66
"buildkite.yaml",
@@ -326,6 +326,14 @@
326326
"What’s the code name for this release? :name_badge:"
327327
]
328328
},
329+
"format": {
330+
"type": "string",
331+
"description": "The format must be a regular expression implicitly anchored to the beginning and end of the input and is functionally equivalent to the HTML5 pattern attribute.",
332+
"format": "regex",
333+
"examples": [
334+
"[0-9a-f]+"
335+
]
336+
},
329337
"required": {
330338
"type": "boolean",
331339
"default": true,

test/schema.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const validate = (name) => {
99
const pipeline = yaml.safeLoad(fs.readFileSync(`./valid-pipelines/${name}`, 'utf8'))
1010

1111
const ajv = new Ajv({ allErrors: true })
12-
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'))
1312
var validate = ajv.compile(schema)
1413

1514
var valid = validate(pipeline)

test/valid-pipelines/input.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
steps:
22
# Different nesting formats
3-
43
- input
54

65
- input: "A label"
@@ -17,7 +16,6 @@ steps:
1716
key: "field-1"
1817

1918
# All the options
20-
2119
- input: "A label"
2220

2321
- input: "A label"
@@ -101,12 +99,24 @@ steps:
10199
- label: "Option 2"
102100
value: option-2
103101

104-
# Key formats
105-
102+
# Text field formats
103+
- input: "A label"
104+
prompt: "A prompt"
105+
fields:
106+
- text: "Formatted field 1"
107+
key: "formatted-field-1"
108+
format: "\\d{4,4}"
109+
- text: "Formatted field 2"
110+
key: "formatted-field-2"
111+
format: "[0-9]{3}"
112+
- text: "Formatted field 3"
113+
key: "formatted-field-3"
114+
format: "[0-9a-f]+"
115+
116+
# Key formats
106117
- input: "Tests for key formatting"
107118
fields:
108119
# Text fields
109-
110120
- text: "Alphanumeric key, leading characters alpha"
111121
key: aBc123
112122
- text: "Alphanumeric key, leading characters numeric"
@@ -123,7 +133,6 @@ steps:
123133
key: -dasherized-key
124134

125135
# Select fields
126-
127136
- select: "Alphanumeric key, leading characters alpha"
128137
key: aBc123
129138
multiple: true

0 commit comments

Comments
 (0)