Giter Club home page Giter Club logo

Comments (4)

felangel avatar felangel commented on June 19, 2024 14

Hi @guissalustiano 👋
Thanks for opening an issue and for the positive feedback!

You should probably have two Password inputs one for the original password (Password) and one for the confirmed password (ConfirmedPassword).

Then in the ConfirmedPassword input you can inject the original password via the dirty constructor like so:

class ConfirmedPassword extends FormzInput<String, PasswordFieldValidationError> {
  const ConfirmedPassword.pure() : original = const Password.pure(), super.pure('');
  const ConfirmedPassword.dirty({@required this.original, String value = ''}) : super.dirty(value);

  final Password original;

  @override
  PasswordFieldValidationError validator(String value) {
    // you now have access to the original password here via `original`
  }
}

Hope that helps 👍

from formz.

herman-the-worm avatar herman-the-worm commented on June 19, 2024

I am curious to how this would work out if there are 2 inputs that have to be validated against each other.

This method won't work anymore since 2 objects cannot co-create each other.

@felangel what would be a direction in this case?

The example of would be 2 time entries that need to be verified against each other.

Like start time and end time.

If I add the code example from above the the end_time field then it is only verified against start_time. But start_time is not verified against the initial field and I am struggling to find an elegant solution to solve this.

from formz.

GsProjects avatar GsProjects commented on June 19, 2024

Hi @felangel,

I'm a little confused when you say you "inject" the original password in the confirmed password class without having to provide it as a parameter in a function etc. Where is the password variable being passed to the confirmPassword class or how is it actually obtaining the original password value.

Basically I'm just wondering if you could elaborate on the "inject" part and how the confirmedPassword class actually gains access to the original password value. Thanks

Edit: Maybe you could provide a detailed textual representation of exactly whats happing in the .pure() and .dirty() lines. This would be hugely beneficial I think

from formz.

felangel avatar felangel commented on June 19, 2024

Hi @felangel,

I'm a little confused when you say you "inject" the original password in the confirmed password class without having to provide it as a parameter in a function etc. Where is the password variable being passed to the confirmPassword class or how is it actually obtaining the original password value.

Basically I'm just wondering if you could elaborate on the "inject" part and how the confirmedPassword class actually gains access to the original password value. Thanks

Edit: Maybe you could provide a detailed textual representation of exactly whats happing in the .pure() and .dirty() lines. This would be hugely beneficial I think

It's just injected via constructor when the FormzInput is instantiated. You can take a look at the bloc firebase login example to see it in action.

Hope that helps 👍

from formz.

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.