GithubHelp home page GithubHelp logo

Comments (4)

eddyystop avatar eddyystop commented on June 22, 2024

You have not mentioned adding validation hooks to the service's hooks. Perhaps you did not do so.

The generator exports validation hooks in src/services/name/name.validations.js. You should add what validations you want to src/services/name/name.hooks.js.

The generator does not automatically add them. I have created #79 to discuss if that should be done, or its too presumtuous.

Please let me if you added the hooks manually or not. Thanks.

from generator-feathers-plus.

eddyystop avatar eddyystop commented on June 22, 2024

I mentioned this to Marshall, another Feathers core maintainer. His view about the validation hooks is "you can’t make assumptions about where to put them, really."

from generator-feathers-plus.

samburgers avatar samburgers commented on June 22, 2024

I didn't make any changes other than i outlined above, and wasn't aware the servicename.hooks.js file needed updating for some of the validations but thats great to know.

Worth noting some validations such as enum already seem to make it over to the Mongoose schema after generate all
ie from my generated src/services/servicename/servicename.mongoose.js

someProp: {
      type: String,
      enum: [
        "option1",
        "option2",
        "option3"
      ]
    },

do you have a basic example of the correct way to declare validations in the name.hooks.js file? Thanks!

from generator-feathers-plus.

eddyystop avatar eddyystop commented on June 22, 2024

The name.validations.?s module exports various validation hooks, etc.

let moduleExports = {
  create,
  update,
  patch,
  validateCreate,
  validateUpdate,
  validatePatch,
  quickValidate,
  // !code: moduleExports // !end
};

Look at the source to see what they do. Just include what you need where you need it, e.g.

before: {
  create: [ ..., validateCreate(), ...]
}

I assume you know how to write and wire up hooks, but just in case.

common hook validateSchema:
https://feathers-plus.github.io/v1/feathers-hooks-common/index.html#validateschema

Hooks Buzzard version docs:
https://docs.feathersjs.com/guides/chat/processing.html
https://docs.feathersjs.com/api/hooks.html

Hooks Auk version docs:
Starting at https://auk.docs.feathersjs.com/guides/step-by-step/basic-feathers/hooks-middleware.html

from generator-feathers-plus.

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.