Coder Social home page Coder Social logo

Comments (4)

epiphone avatar epiphone commented on June 20, 2024 1

Which JSON Schema property do you propose using here?

from class-validator-jsonschema.

yab94 avatar yab94 commented on June 20, 2024 1

Hi,
I am speaking about this message :
https://github.com/typestack/class-validator#validation-messages

from class-validator-jsonschema.

yab94 avatar yab94 commented on June 20, 2024

Hi Epiphone,

I would like your code to fill this JSON property :

ValidationSchema.properties.propertyName.message

This can be done by adding this block of code at line 128 of src/index.ts.

    let items = _.isFunction(converter) ? converter(meta, options) : converter

    if(meta.message) {
      items = {
        ...items,
        message: meta.message,
      } 
    }

My goal is that the backend can generates a rules file based on decorators and then the frontend can receives these rules to validate with the same rules that the backend without any differences between front and back rules. And all these rules will be coded with decorators in backend entities (typeorm) only once.
I just want to share the validation rules between front and back, and i wan't to include the error message in the transfered schema.
This transfert will be done just by a simple REST API like "GET /api/v1/books/rules".

from class-validator-jsonschema.

epiphone avatar epiphone commented on June 20, 2024

There's no message property in JSON Schema though, is there? I think supporting non-schema properties is outside the scope of this library. You might want to try using one of the provided extension points or going with a fork.

from class-validator-jsonschema.

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.