Giter Club home page Giter Club logo

Comments (3)

zeshuaro avatar zeshuaro commented on June 16, 2024 3

@dbof10, using your example, You can check for the error status like this:

BlocListener<QuoteDownloadCubit, QuoteDownloadState>(
  listener: (context, state) {
    if (state.symbol.error == SymbolValidationError.invalid) {
      // Handle invalid error
    }
    // Add more if statements as required
  },
);

from formz.

felangel avatar felangel commented on June 16, 2024

Hi @dbof10 👋
Thanks for opening an issue!

You should be able to leverage the error property on your custom FormzInput to differentiate between different errors on at the individual input level. For broad form-level errors you can define your own state to encapsulate the FormzStatus along with any additional meta data. Let me know if that helps and if not, could you please share the link to a sample app which illustrates the issue you're facing? Thanks! 🙏

from formz.

dbof10 avatar dbof10 commented on June 16, 2024

I have a simple class

enum SymbolValidationError { invalid }

class Symbol extends FormzInput<String, SymbolValidationError> {
  const Symbol.pure() : super.pure('');

  const Symbol.dirty([String value = '']) : super.dirty(value);

  @override
  SymbolValidationError validator(String value) {
    return value.isNotEmpty ? null : SymbolValidationError.invalid;
  }
}
 BlocListener<QuoteDownloadCubit, QuoteDownloadState>(
      listener: (context, state) {
        
      },
    );

State class

class QuoteDownloadState extends Equatable {

  Symbol symbol;
  FormzStatus status;

}

I just follow your example for login. Symbol returns SymbolValidationError. I dont see a place where I can access the a specific error type like you answered above. State has status. Status is a predefine enum. If I add more fields in the State class, it will solve my problem. I just want to leverage what the lib offers or what is recommended to do with this library.

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.