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.

can the Form execute different validator by different trigger?

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

eg: There is an input-component, which need to validate the format and calculate the value. such as ID Card No input-component. I want to validate the format while inputting and to calculate the value while being finished. I wish when the inputting doesn’t finish, it can’t return an error. Because if return an error, it isn’t friendly. But when the on-blur happened, it can return an error “Please input the correct format!”

codepen: https://codepen.io/panjunfen/pen/VNrLpr?editors=0010

What does the proposed API look like?

in the rule object, add a key “trigger”. such as, [{ pattern: /^([A-Z]{0,2}|[A-Z]{1,2}\d{0,6}|[A-Z]{1,2}\d{6}([0-9A]{0,1}){0,1})$/, trigger: ‘onChange’, },{ validator: (rule, value, callback)=>{ console.log(validator value:${value} rule:,rule); if(!value || value.search(/^[A-Z]{1,2}\d{6}([0-9A])$/) == -1){ callback(); return ; } if(validHKID(value)){ callback(); } else { callback(“The ID is incorrect!”); } }, trigger: ‘onChange’ },{ pattern: /^[A-Z]{1,2}\d{6}([0-9A])$/, trigger: ‘onBlur’ }]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zombieJcommented, Apr 4, 2021

https://codesandbox.io/s/jibenshiyong-antd4150-forked-k7rfu?file=/index.js

antd v4 enabled rules with different triggerValidator. Seems this issue can be closed now.

0reactions
kmerazcommented, Jun 27, 2022

just clarifying that @zombieJ meant validateTrigger

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to trigger Form Validators in Angular2 - Stack Overflow
This should trigger and run the validators. ... Here is another similar way that also uses markAsDirty and updateValueAndValidity, ...
Read more >
TIP: Trigger Validation In Reactive Forms
Be aware not all validations are triggerd , just the validation of the form control you are changing. It casts the outcome to...
Read more >
Trigger plugin - FormValidation
In the following form, the Title field will be validated while user type any character ( trigger="keyup" ). The Summary field will be...
Read more >
Angular Reactive Forms: trigger validation on submit
In this article we will learn different approaches of validating all form fields when user clicks on submit button for Angular Reactive ...
Read more >
In Oracle Forms, to run all the When-Validate-Item of all the ...
as Sandy wrote, putting the WHEN-VALIDATE-ITEM trigger on block level (or even form level) will do the validation for every item immediatly. if ......
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