question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch on autovalidation on FormState

See original GitHub issue

In this case autovalidation on FormState is not working, I mean value => !value.Name.$.trim() && 'Value is required' is not checking

newTemplate = new FormState({
    Name: new InputFieldState<string>('name').validators(value => this.isNameUsed(value) && 'This name is used'),
    CampaignType: new DropdownFieldState<CampaignType>(CampaignType.Default)
}).compose().validators(value => !value.Name.$.trim() && 'Value is required');

Validator on FormState starts autovalidating only if onChange method of all the FieldState-s are called and changes theirs values.

this.newTemplate.$.Name.onChange('');
this.newTemplate.$.CampaignType.onChange(CampaignType.IdleAccount);

Can you help me, please?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
basaratcommented, May 2, 2019

Thank you for your excellent reproduction and patience. Sorry for the previous poor design choice on when to fire form validators (onChangeAfterValidationPass). Changed to match your (and now mine) intuition (onValidationPass) 👍 1.3.0 🌹

1reaction
basaratcommented, Apr 30, 2019

Can we add some changes to switch on FormState autovalidation right away when it is needed?

formState.enableAutoValidationAndValidate() will do that 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

allow `FormFieldState` the option to not validate initially when ...
This is a different behaviour than FormState when autoValidate is set to true ... the field will be validated immediately when created and...
Read more >
Flutter: Change state depending on validation - Stack Overflow
If autovalidate is turned on, then function passed as validator will be called in FormFieldState.build method to update error text.
Read more >
Flutter Forms Validation — the Ultimate Guide - Medium
A form's FormState has two methods, validate() and save() , which open ... Next, turn on autovalidation by adding autovalidate to the Form ......
Read more >
useForm - FormState - Simple React forms validation
This object contains information about the entire form state. It helps you to keep on track with the user's interaction with your form...
Read more >
React form validation solutions: An ultimate roundup
This roundup is a comprehensive look at some of the most popular solutions for form management and validation in React.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found