Skip to content

loopback saves data with invalid Date property #1035

@aantipov

Description

@aantipov

Hi,
I use loopback version 2.10.2.
I have a model with a base "PersistedModel" and defined some properties on it.

{
  "name": "Hike",
  "base": "PersistedModel",
  "idInjection": true,
  "properties": {
    "title": {
      "type": "string",
      "required": true
    },
    "desc": {
      "type": "string"
    },
    "created": {
      "type": "date",
      "required": true
    }
  },
  "validations": [],
  "relations": {
    "author": {
      "type": "belongsTo",
      "model": "Account",
      "foreignKey": "authorId"
    }
  },
  "acls": [],
  "methods": []
}

Note that property created is required.

When I try to save a new object with invalid created property, the object is successfully saved & stored value for that property is null.

Here is a screenshot from api explorer with a post operation https://www.dropbox.com/s/cbdlyb0a6uv51au/save-invalid-date.png

Is it a bug?

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions