Skip to content

Parameter check error #2526

@Anthony-Zeng

Description

@Anthony-Zeng

I define the request parameter rule to be

 params do
  requires :workflow_nodes, type: Array do
    requires :id, type: String
    requires :title, type: String
    optional :is_start, type: Boolean
    requires :steps, type: Array do
      requires :id, type: String
      optional :type, type: String, values: %w[send_messsge assign_user assign_team tag_conversation snooze close add_commit]
      given type: ->(val) { val == 'send_messsge' } do
        requires :message, type: Hash do
          requires :content, type: String
        end
      end
      given type: ->(val) { val == 'assign_user' } do
        requires :assign_user_id, type: String
      end
      given type: ->(val) { val == 'assign_team' } do
        requires :assign_team_id, type: String
      end
      given type: ->(val) { val == 'tag_conversation' } do
        requires :tags, type: Array[String]
      end
      given type: ->(val) { val == 'add_commit' } do
        requires :comment_content, type: String
      end
     end
  end
end

The content of my request is

{
 "workflow_nodes": [
  {
    "id": "eqibmvEzPo8hQOSt",
    "title": "Node 1",
    "is_start": true,
    "steps": [
      {
        "id": "DvdSZaIm1hEd5XO5",
        "type": "send_messsge",
        "message": {
          "content": "打击好",
          "menus": []
        }
      },
      {
        "id": "VY6MIwycBw0b51Ib",
        "type": "add_commit",
        "comment_content": "初来乍到"
      }
    ]
  }
 ]
}

However, the request returns an inspection error message workflow_nodes[0][steps][0][message][content] is missing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions