ditojs / dito-example

4 stars 2 forks source link

[wip] Fix creating messages #5

Closed puckey closed 4 years ago

puckey commented 4 years ago

While it does now send a request to the server, it returns a validation error:

The patch request to /api/admin/dummies/2 with the following payload:

{
  id: 2,
  firstName: "Audrey",
  lastName: "02 Marcelina",
  prefix: "mr",
  country: "NA",
  dateOfBirth: "2015-10-23T03:11:02.018Z",
  email: "Oleta_Barton48@yahoo.com",
  age: 24,
  factor: 0.51,
  tags: ["Writer"],
  colors: ["blue"],
  verified: false,
  comments: "Voluptatem veritatis aspernatur.",
  createdAt: "2020-07-16T12:59:31.028Z",
  updatedAt: "2020-07-16T12:59:31.028Z",
  messages: [
    {
      id: 5,
      dummyId: 2,
      text: "Possimus optio et error molestiae architecto officiis cumque.",
      createdAt: "2020-07-16T12:59:31.103Z",
      updatedAt: "2020-07-16T12:59:31.103Z"
    },
    {
      id: 6,
      dummyId: 2,
      text: "Velit quasi error debitis.",
      createdAt: "2020-07-16T12:59:31.104Z",
      updatedAt: "2020-07-16T12:59:31.104Z"
    },
    {
      id: 7,
      dummyId: 2,
      text: "Est exercitationem tenetur nisi enim culpa quos ullam.",
      createdAt: "2020-07-16T12:59:31.105Z",
      updatedAt: "2020-07-16T12:59:31.105Z"
    },
    {
      id: 8,
      dummyId: 2,
      text: "Iusto officiis repellat placeat quasi dolor fuga harum.",
      createdAt: "2020-07-16T12:59:31.106Z",
      updatedAt: "2020-07-16T12:59:31.106Z"
    },
    {
      id: 9,
      dummyId: 2,
      text: "Cupiditate reiciendis quaerat suscipit est laudantium quia.",
      createdAt: "2020-07-16T12:59:31.107Z",
      updatedAt: "2020-07-16T12:59:31.107Z"
    },
    {
      id: 10,
      dummyId: 2,
      text: "Commodi in velit illum aut autem error eveniet illum.",
      createdAt: "2020-07-16T12:59:31.108Z",
      updatedAt: "2020-07-16T12:59:31.108Z"
    },
    {
      id: 11,
      dummyId: 2,
      text: "Non ea quasi.",
      createdAt: "2020-07-16T12:59:31.109Z",
      updatedAt: "2020-07-16T12:59:31.109Z"
    },
    { text: "sss" }
  ],
  fullName: "Audrey 02 Marcelina"
};

returns the following error with code 400:

{
  message: "The provided data for the Message model is not valid",
  type: "ModelValidation",
  errors: {
    "messages[7].text": [
      {
        message: "is a required property",
        keyword: "required",
        params: { missingProperty: "text" }
      }
    ]
  }
}