From 644e96ae457047ce09f55aa1f14a42c41dbc1dc8 Mon Sep 17 00:00:00 2001 From: Moshe Eshel Date: Sat, 27 Jun 2020 11:45:00 -0400 Subject: [PATCH] feat: array size info based on min max Items properties (#1308) --- src/components/Schema/ArraySchema.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Schema/ArraySchema.tsx b/src/components/Schema/ArraySchema.tsx index eb8124b2f3..48e7dc4135 100644 --- a/src/components/Schema/ArraySchema.tsx +++ b/src/components/Schema/ArraySchema.tsx @@ -4,6 +4,7 @@ import { Schema, SchemaProps } from './Schema'; import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements'; import styled from '../../styled-components'; +import {humanizeConstraints} from "../../utils"; const PaddedSchema = styled.div` padding-left: ${({ theme }) => theme.spacing.unit * 2}px; @@ -12,9 +13,16 @@ const PaddedSchema = styled.div` export class ArraySchema extends React.PureComponent { render() { const itemsSchema = this.props.schema.items!; + const itemConstraintSchema = ( + min: number | undefined = undefined, + max: number | undefined = undefined, + ) => ({ type: 'array', minItems: min, maxItems: max }); + + const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems)); + return (
- Array + Array ({minMaxItems})