Skip to content

Commit f731704

Browse files
authored
Merge pull request #43 from pinanks/DOT-2299
Fix selector validation in snapshot options
2 parents 88f9df6 + 50e913c commit f731704

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/lib/schemaValidation.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,27 @@ const SnapshotSchema: JSONSchemaType<Snapshot> = {
129129
properties: {
130130
id: {
131131
type: "array",
132-
items: { type: "string", minLength: 1 },
132+
items: { type: "string", minLength: 1, pattern: "^[^;]*$", errorMessage: "Invalid snapshot options; id cannot be empty or have semicolon" },
133133
uniqueItems: true,
134-
errorMessage: "Invalid snapshot options; id array must be of unique and non-empty items"
134+
errorMessage: "Invalid snapshot options; id array must have unique items"
135135
},
136136
class: {
137137
type: "array",
138-
items: { type: "string", minLength: 1 },
138+
items: { type: "string", minLength: 1, pattern: "^[^;]*$", errorMessage: "Invalid snapshot options; class cannot be empty or have semicolon" },
139139
uniqueItems: true,
140-
errorMessage: "Invalid snapshot options; class array must be of unique and non-empty items"
140+
errorMessage: "Invalid snapshot options; class array must have unique items"
141141
},
142142
cssSelector: {
143143
type: "array",
144-
items: { type: "string", minLength: 1 },
144+
items: { type: "string", minLength: 1, pattern: "^[^;]*$", errorMessage: "Invalid snapshot options; cssSelector cannot be empty or have semicolon" },
145145
uniqueItems: true,
146-
errorMessage: "Invalid snapshot options; cssSelector array must be of unique and non-empty items"
146+
errorMessage: "Invalid snapshot options; cssSelector array must have unique items"
147147
},
148148
xpath: {
149149
type: "array",
150150
items: { type: "string", minLength: 1 },
151151
uniqueItems: true,
152-
errorMessage: "Invalid snapshot options; xpath array must be of unique and non-empty items"
152+
errorMessage: "Invalid snapshot options; xpath array must have unique and non-empty items"
153153
},
154154
}
155155
},
@@ -158,28 +158,28 @@ const SnapshotSchema: JSONSchemaType<Snapshot> = {
158158
properties: {
159159
id: {
160160
type: "array",
161-
items: { type: "string", minLength: 1 },
161+
items: { type: "string", minLength: 1, pattern: "^[^;]*$", errorMessage: "Invalid snapshot options; id cannot be empty or have semicolon" },
162162
uniqueItems: true,
163-
errorMessage: "Invalid snapshot options; id array must be of unique and non-empty items"
163+
errorMessage: "Invalid snapshot options; id array must have unique items"
164164
},
165165
class: {
166166
type: "array",
167-
items: { type: "string", minLength: 1 },
167+
items: { type: "string", minLength: 1, pattern: "^[^;]*$", errorMessage: "Invalid snapshot options; class cannot be empty or have semicolon" },
168168
uniqueItems: true,
169-
errorMessage: "Invalid snapshot options; class array must be of unique and non-empty items"
169+
errorMessage: "Invalid snapshot options; class array must have unique items"
170170
},
171171
cssSelector: {
172172
type: "array",
173-
items: { type: "string", minLength: 1 },
173+
items: { type: "string", minLength: 1, pattern: "^[^;]*$", errorMessage: "Invalid snapshot options; cssSelector cannot be empty or have semicolon" },
174174
uniqueItems: true,
175-
errorMessage: "Invalid snapshot options; cssSelector array must be of unique and non-empty items"
175+
errorMessage: "Invalid snapshot options; cssSelector array must have unique items"
176176
},
177177
xpath: {
178178
type: "array",
179179
items: { type: "string", minLength: 1 },
180180
uniqueItems: true,
181-
errorMessage: "Invalid snapshot options; xpath array must be of unique and non-empty items"
182-
},
181+
errorMessage: "Invalid snapshot options; xpath array must have unique and non-empty items"
182+
},
183183
}
184184
}
185185
},

0 commit comments

Comments
 (0)