Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #34 from zapier/validate-children
Browse files Browse the repository at this point in the history
Correctly Validate `children` as an array of fields.
  • Loading branch information
xavdid authored Mar 9, 2018
2 parents ea85d65 + 2c8e4cf commit 66fb66d
Show file tree
Hide file tree
Showing 5 changed files with 3,301 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.10.2
v6.10.3
3 changes: 2 additions & 1 deletion docs/build/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ Defines a field an app either needs as input, or gives as output.
* `{ key: 'abc', choices: [ { label: 'Red', value: '#f00' } ] }`
* `{ key: 'abc', choices: 'mobile' }`
* `{ key: 'abc', type: 'loltype' }`
* `{ key: 'abc', children: [ '$func$2$f$' ] }`

#### Properties

Expand All @@ -602,7 +603,7 @@ Key | Required | Type | Description
`search` | no | [/RefResourceSchema](#refresourceschema) | A reference to a search that will guide the user to add a search step to populate this field when creating a Zap.
`choices` | no | [/FieldChoicesSchema](#fieldchoicesschema) | An object of machine keys and human values to populate a static dropdown.
`list` | no | `boolean` | Can a user provide multiples of this field?
`children` | no | _n/a_ | An array of child fields that define the structure of a sub-object for this field. Usually used for line items.
`children` | no | `array`[[/FieldSchema](#fieldschema)] | An array of child fields that define the structure of a sub-object for this field. Usually used for line items.
`dict` | no | `boolean` | Is this field a key/value input?
`computed` | no | `boolean` | Is this field automatically populated (and hidden from the user)?
`altersDynamicFields` | no | `boolean` | Does the value of this field affect the definitions of other fields in the set?
Expand Down
4 changes: 4 additions & 0 deletions exported-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@
"type": "boolean"
},
"children": {
"type": "array",
"items": {
"$ref": "/FieldSchema"
},
"description":
"An array of child fields that define the structure of a sub-object for this field. Usually used for line items."
},
Expand Down
10 changes: 5 additions & 5 deletions lib/schemas/FieldSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

const makeSchema = require('../utils/makeSchema');

const FieldsSchema = require('./FieldsSchema');

const RefResourceSchema = require('./RefResourceSchema');

const FieldChoicesSchema = require('./FieldChoicesSchema');
Expand Down Expand Up @@ -34,7 +32,8 @@ module.exports = makeSchema(
{ key: 'abc', choices: [3] },
{ key: 'abc', choices: [{ label: 'Red', value: '#f00' }] },
{ key: 'abc', choices: 'mobile' },
{ key: 'abc', type: 'loltype' }
{ key: 'abc', type: 'loltype' },
{ key: 'abc', children: ['$func$2$f$'] }
],
required: ['key'],
properties: {
Expand Down Expand Up @@ -110,9 +109,10 @@ module.exports = makeSchema(
type: 'boolean'
},
children: {
type: 'array',
items: { $ref: '/FieldSchema' },
description:
'An array of child fields that define the structure of a sub-object for this field. Usually used for line items.',
$ref: FieldsSchema.id
'An array of child fields that define the structure of a sub-object for this field. Usually used for line items.'
},
dict: {
description: 'Is this field a key/value input?',
Expand Down
Loading

0 comments on commit 66fb66d

Please sign in to comment.