-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(json-schema-2020-12): add support for dependentRequired keyword (#…
- Loading branch information
Showing
10 changed files
with
276 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...e/plugins/json-schema-2020-12/components/keywords/DependentRequired/DependentRequired.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
|
||
import * as propTypes from "../../../prop-types" | ||
|
||
const DependentRequired = ({ dependentRequired }) => { | ||
if (dependentRequired.length === 0) return null | ||
|
||
return ( | ||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--dependentRequired"> | ||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--primary"> | ||
Required when defined | ||
</span> | ||
<ul> | ||
{dependentRequired.map((propertyName) => ( | ||
<li key={propertyName}> | ||
<span className="json-schema-2020-12-keyword__value json-schema-2020-12-keyword__value--warning"> | ||
{propertyName} | ||
</span> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
||
DependentRequired.propTypes = { | ||
schema: propTypes.schema.isRequired, | ||
dependentRequired: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
} | ||
|
||
export default DependentRequired |
Oops, something went wrong.