Git Product home page Git Product logo

Comments (7)

arnaudbesnier avatar arnaudbesnier commented on June 19, 2024 1

The fix has been release in the 1.1.5 liana version. Here are the changelogs.

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on June 19, 2024

Hi @gunar, validation is not something the current liana manage properly.
We definitely want to improve this, in the future releases.

As you may notice, we have a PRΒ in review to support simple validations here: #35

But you seem to have complex validations. We would love to have a small example of your complex validation to help us implement it.

🌲🌲🌲

from forest-express-mongoose.

gunar avatar gunar commented on June 19, 2024

Hi @arnaudbesnier
Thanks for the quick response

Why it is needed to implement code for validation?
If you take my model and do instance.save() it will throw, in case of validation errors
Isn't that what forest-express-mongoose does?

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on June 19, 2024

@gunar sorry for the misunderstanding... The PR I showed you is a feature to improve the validation experience.

You are right, as the liana is based on the Mongoose ORM. It means that the validations you defined in your models should work while using Forest.
If I understand well, you are submitting an issue here, right?
Your custom validations are simply not executed or do you notice another unexpected behaviour?

Can you provide a simple code example based on your code, that we could use to reproduce the issue?

from forest-express-mongoose.

gunar avatar gunar commented on June 19, 2024

Thank you for the feedback
Here's the code https://github.com/gunar/forestRepro
Validators are not being checked on updates (only on inserts, it seems)

Validator on insert works

Create
bitcoin.code = 'ZZZ'
Then try to create
litecoin.code = 'ZZZ'
I get a validation error

Validator on update does not work

Create
bitcoin.code = 'ZZZ'
litecoin.code = 'ZZA'
Then update
litecoin.code = 'ZZZ'
I get no validation error, but should have

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on June 19, 2024

@gunar Ok I think I found the reason why the validations are not triggered on record update. I think the method findByIdAndUpdate (https://github.com/ForestAdmin/forest-express-mongoose/blob/devel/services/resource-updater.js#L19) needs to have the runValidators option set to true which is not the case.

Let me reproduce and fix this week.

from forest-express-mongoose.

arnaudbesnier avatar arnaudbesnier commented on June 19, 2024

@gunar can you check if the PR fixes your issue?

from forest-express-mongoose.

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.