Skip to content

Support enum for array items #152

@JDziurlaj

Description

@JDziurlaj

I've run into a situation where the definition of a field as type: "array" and an enum constraint results in the fieldName becoming listed as undefined

const TF = {
  fields: [{
    "name": "ApplicationRequestStatusType",
    "type": "array",
    "title": "Application Request Status",
    "description": "description goes here.",
    "constraints": {
      "required": true,
      "enum": [
        "duplicate",
        "invalid",
        "valid",
        "other"
      ]
    }
  }],
}

// Tests
describe('Schema', () => {

  it('specify correct fieldName', async () => {
    {
      const schema = await Schema.load(TF)
     //FAIL
     assert.equal(schema.fieldNames[0], "ApplicationRequestStatusType")
    }
    delete TF.fields[0].constraints
    {
      const schema = await Schema.load(TF)
      //PASS
      assert.equal(schema.fieldNames[0], "ApplicationRequestStatusType")
    }

  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions