Skip to content

Commit 3a18c4d

Browse files
authored
fix(core): validate pattern if specified for a schema property (#6395)
1 parent 596cf5b commit 3a18c4d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/tao/src/shared/params.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ function validateProperty(
243243
)}.`
244244
);
245245
}
246+
247+
if (schema.type === 'string' && schema.pattern) {
248+
if (!new RegExp(schema.pattern).test(value)) {
249+
throw new SchemaError(
250+
`Property '${propName}' does not match the schema. '${value}' should match the pattern '${schema.pattern}'.`
251+
);
252+
}
253+
}
246254
} else if (Array.isArray(value)) {
247255
if (schema.type !== 'array') throwInvalidSchema(propName, schema);
248256
value.forEach((valueInArray) =>

0 commit comments

Comments
 (0)