in language-service/src/parser/jsonParser.ts [308:336]
protected validateStringValue(schema: JSONSchema, value: string, validationResult: ValidationResult): void {
if (schema.minLength && value.length < schema.minLength) {
validationResult.addProblem({
location: { start: this.start, end: this.end },
severity: ProblemSeverity.Warning,
getMessage: () => localize('minLengthWarning', 'String is shorter than the minimum length of {0}.', schema.minLength)
});
}
if (schema.maxLength && value.length > schema.maxLength) {
validationResult.addProblem({
location: { start: this.start, end: this.end },
severity: ProblemSeverity.Warning,
getMessage: () => localize('maxLengthWarning', 'String is longer than the maximum length of {0}.', schema.maxLength)
});
}
if (schema.pattern) {
const flags: string = ASTNode.getIgnoreValueCase(schema) ? "i" : "";
const regex: RegExp = new RegExp(schema.pattern, flags);
if (!regex.test(value)) {
validationResult.addProblem({
location: { start: this.start, end: this.end },
severity: ProblemSeverity.Warning,
getMessage: () => schema.patternErrorMessage || schema.errorMessage || localize('patternWarning', 'String does not match the pattern of "{0}".', schema.pattern)
});
}
}
}