Code Monkey home page Code Monkey logo

Comments (12)

nsoufian avatar nsoufian commented on June 3, 2024

@zysktomasz You want to pass a function that can manipulate related rules if you see the documentation of related field you can see that you can pass another element to the array as a callback that get related-field data as input and must return a value.

Field().custom(["#someField", x => x.Uppercase()], callbackValidator);

from v4f.

chrisneal avatar chrisneal commented on June 3, 2024

@reyx7 That doesn't work. The callbackValidator never gets called. Any ideas?

from v4f.

nsoufian avatar nsoufian commented on June 3, 2024

@chrisneal can you make a sandbox for these issues

from v4f.

chrisneal avatar chrisneal commented on June 3, 2024

@reyx7 https://codesandbox.io/s/3km1h

from v4f.

nsoufian avatar nsoufian commented on June 3, 2024

@chrisneal it works correctly, the costum rule only takes an array with two elements the ["Field Name", callback_function], check out the API reference for more information.

If your problem is not resolved open a new issue with detailed pieces of information, that will help to workaround the issue.

@chrisneal thanks for your feedback

from v4f.

chrisneal avatar chrisneal commented on June 3, 2024

@reyx7 In your reply to zysktomasz above, you mention that you can use a custom field with a callback, and then an additional callback.

Field().custom(
  [
    "#someField", 
    x => x.Uppercase()
  ], 
  callbackValidator
);

In my sandbox example, I have:

Field().custom(
  [
    "#endedAt",
    endedAt => {
      console.log(endedAt);
      return true;
    }
  ],
  startedAt => {
    console.log(startedAt);
    return true;
  }
)

So are you saying that your reply to zysktomasz is incorrect?

from v4f.

nsoufian avatar nsoufian commented on June 3, 2024

@chrisneal Please read the documentation carefully.

from v4f.

chrisneal avatar chrisneal commented on June 3, 2024

@reyx7 I have... Could you at least answer my question?

from v4f.

nsoufian avatar nsoufian commented on June 3, 2024

@chrisneal please give some time to the documentation and try to understand the library,
and try the examples in the documentation.

from v4f.

chrisneal avatar chrisneal commented on June 3, 2024

@reyx7 I have read the documentation, and looked through the code. I was purely referencing your comment above. I can't see any evidence of it working the way it does above, but you're the author, and you're the one that gave the example code. So I'm assuming that the code in your comment above is wrong?

from v4f.

nsoufian avatar nsoufian commented on June 3, 2024

@chrisneal can you please make a clear example in the sandbox , the library is fine all rules are well tested you have miss understood something.

from v4f.

chrisneal avatar chrisneal commented on June 3, 2024

@reyx7 I posted a sandbox link above (https://codesandbox.io/s/3km1h), as well as called out the specific code from my sandbox here:
#57 (comment)

from v4f.

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.