Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(json-schema-2020-12): add support for contentEncoding keyword #8644

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import classNames from "classnames"
* from JSON Schema 2020-12 validation vocabulary.
*/
const Constraint = ({ constraint }) => {
const isPattern = /^matches /.test(constraint)
const isStringRange = /characters$/.test(constraint)
const isContentMediaType = /^media type: /
const isStringRelated = isPattern || isStringRange || isContentMediaType
const isStringRelated =
/^matches /.test(constraint) || // pattern keyword
/characters$/.test(constraint) || // minLength, maxLength keywords
/^media type: /.test(constraint) || // contentMediaType keyword
/^encoding: /.test(constraint) // contentEncoding keyword

return (
<span
Expand Down
3 changes: 3 additions & 0 deletions src/core/plugins/json-schema-2020-12/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ export const stringifyConstraints = (schema) => {
if (schema?.contentMediaType) {
constraints.push(`media type: ${schema.contentMediaType}`)
}
if (schema?.contentEncoding) {
constraints.push(`encoding: ${schema.contentEncoding}`)
}

return constraints
}
Expand Down