Repository: vazco/uniforms (ts)

Issue:
Feature: Missing JSON Schema properties
While implementing a form based on JSON Schema generated by [pydantic](https://github.com/samuelcolvin/pydantic/). I noticed a few JSON Schema properties that are not handled. See also [their docs](https://pydantic-docs.helpmanual.io/usage/schema/#json-schema-types) about JSON Schema properties.

Effectively I need to override `getProps` in the bridge with:
```ts
    getProps(name: string) {
        let props = super.getProps(name);

        if (props.const) {
            props.disabled = true;
            props.default = props.const;
            delete props["const"];
        }

        if (props.maxItems !== undefined) {
            props.maxCount = props.maxItems;
            delete props["maxItems"];
        }

        if (props.minItems !== undefined) {
            props.minCount = props.minItems;
            delete props["minItems"];
        }

        if (props.maximum !== undefined) {
            props.max = props.maximum;
            delete props["maximum"];
        }

        if (props.minimum !== undefined) {
            props.min = props.minimum;
            delete props["minimum"];
        }

        if (props.multipleOf !== undefined) {
            props.step = props.multipleOf;
            delete props["multipleOf"];
        }

        return props;
    }
```

I am not sure about the supported JSON Schema specs and whether these properties are in scope of being supported by default. And I am not sure if it is a valid asumption that `const` is read only. But I feel at least some might be worth to implement in the base JSONSchemaBridge. 

I don't know if this list is complete, its what are missing atm

Pull request:
Add missing JSON Schema properties (closes #748).
Add JSON Schema properties: `maxCount`, `minCount`, `max`, `min`, `step`.

Patch:
diff --git a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts b/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
index 377eac13..a22d20e6 100644
--- a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
+++ b/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
@@ -28,6 +28,14 @@ function resolveRef(reference: string, schema: Record<string, any>) {
   return resolvedReference;
 }
 
+const propMapper: Record<string, string> = {
+  maxItems: 'maxCount',
+  minItems: 'minCount',
+  maximum: 'max',
+  minimum: 'min',
+  multipleOf: 'step',
+};
+
 function distinctSchema(schema: Record<string, any>) {
   if (schema.type === 'object') {
     return schema;
@@ -271,6 +279,14 @@ export default class JSONSchemaBridge extends Bridge {
       }
     }
 
+    Object.keys(ready).forEach(key => {
+      if (key in propMapper) {
+        const newKey = propMapper[key];
+        ready[newKey] = ready[key];
+        delete ready[key];
+      }
+    });
+
     return ready;
   }
 


Test patch:
diff --git a/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts b/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
index 107f9f95..0b7454b1 100644
--- a/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
+++ b/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
@@ -117,7 +117,13 @@ describe('JSONSchemaBridge', () => {
         },
       },
       password: { type: 'string', uniforms: { type: 'password' } },
-      passwordNumeric: { type: 'number', uniforms: { type: 'password' } },
+      passwordNumeric: {
+        type: 'number',
+        uniforms: { type: 'password' },
+        maximum: 9999,
+        minimum: 1000,
+        multipleOf: 3,
+      },
       recursive: { $ref: '#/definitions/recursive' },
       arrayWithAllOf: {
         type: 'array',
@@ -126,6 +132,8 @@ describe('JSONSchemaBridge', () => {
           allOf: [{ required: ['child'] }],
           properties: { child: { type: 'string' } },
         },
+        maxItems: 3,
+        minItems: 1,
       },
     },
     required: ['dateOfBirth'],
@@ -585,6 +593,9 @@ describe('JSONSchemaBridge', () => {
         required: false,
         decimal: true,
         type: 'password',
+        max: 9999,
+        min: 1000,
+        step: 3,
       });
     });
 
@@ -603,6 +614,26 @@ describe('JSONSchemaBridge', () => {
         required: true,
       });
     });
+
+    it('works with maxItems in props', () => {
+      expect(bridge.getProps('arrayWithAllOf')).toHaveProperty('maxCount', 3);
+    });
+
+    it('works with minItems in props', () => {
+      expect(bridge.getProps('arrayWithAllOf')).toHaveProperty('minCount', 1);
+    });
+
+    it('works with maximum in props', () => {
+      expect(bridge.getProps('passwordNumeric')).toHaveProperty('max', 9999);
+    });
+
+    it('works with minimum in props', () => {
+      expect(bridge.getProps('passwordNumeric')).toHaveProperty('min', 1000);
+    });
+
+    it('works with multipleOf in props', () => {
+      expect(bridge.getProps('passwordNumeric')).toHaveProperty('step', 3);
+    });
   });
 
   describe('#getSubfields', () => {