Coder Social home page Coder Social logo

ValidationError: The `user` instance is not valid. Details: `email` is invalid (value: "[email protected]") about loopback-example-access-control HOT 4 CLOSED

liudonghua123 avatar liudonghua123 commented on July 22, 2024
ValidationError: The `user` instance is not valid. Details: `email` is invalid (value: "[email protected]")

from loopback-example-access-control.

Comments (4)

osamasaeed avatar osamasaeed commented on July 22, 2024 1

I have resolved it. assign null to unnecessary fields
"credentials":null,
"challenges":null,
"realm":null,
"status": null,
"created": null,
"lastUpdated": null

in your model. if your base:"User"

from loopback-example-access-control.

tniezurawski avatar tniezurawski commented on July 22, 2024

@liudonghua123 I didn't clone this repo but I'm pretty sure what's going on ;)

Leave db datasource as it was. Set server/datasources.json this way:

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "mysqlDs": {
    "host": "localhost",
    "port": 3306,
    "database": "",
    "username": "",
    "password": "",
    "name": "mysqlDs",
    "connector": "mysql"
  }
}

Yours server/model-config.json should look somehow similar to this:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "loopback/server/mixins",
      "../common/mixins",
      "./mixins"
    ]
  },
  "User": {
    "dataSource": "db"
  },
  "AccessToken": {
    "dataSource": "db",
    "public": false
  },
  "ACL": {
    "dataSource": "db",
    "public": false
  },
  "RoleMapping": {
    "dataSource": "db",
    "public": false,
    "options": {
      "strictObjectIDCoercion": true
    }
  },
  "Role": {
    "dataSource": "db",
    "public": false
  },
  "user": {
    "dataSource": "mysqlDs",
    "public": true
  }
}

Then the part that is the most important here. Most probably there is no tables in DB yet. Wrap all your code in server/boot/create-sample-models.js in automigrate like this:

module.exports = function(app) {
  app.dataSources.mysqlDs.automigrate('user', function(err) {
    // code here
  });
};

It should work. Tell me if doesn't so I will reproduce it.

from loopback-example-access-control.

stale avatar stale commented on July 22, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from loopback-example-access-control.

stale avatar stale commented on July 22, 2024

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

from loopback-example-access-control.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.