Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public API for checking form/field validity #5

Open
chrisdpratt opened this issue Dec 21, 2018 · 3 comments · May be fixed by #9
Open

Public API for checking form/field validity #5

chrisdpratt opened this issue Dec 21, 2018 · 3 comments · May be fixed by #9

Comments

@chrisdpratt
Copy link

Perhaps I missed it, but there doesn't seem to be a way to manually check form/field validity such as exists in jQuery Validation (form.validate(), form.valid(), etc.). The following method exists in the source:

/**
 * Returns a Promise that returns validation result for each and every inputs within the form.
 * @param formUID 
 */
private getFormValidationTask(formUID: string) {
    let formInputUIDs = this.formInputs[formUID];
    if (!formInputUIDs || formInputUIDs.length === 0) {
        return null;
    }

    let formValidators: Validator[] = [];

    for (let i = 0; i < formInputUIDs.length; i++) {
        let inputUID = formInputUIDs[i];
        formValidators.push(this.validators[inputUID]);
    }

    let tasks = formValidators.map(factory => factory());
    return Promise.all(tasks).then(result => result.every(e => e));
}

However, it's private and seems to only support automatic validation on submit. In certain scenarios is necessary to handle the submit event manually and check the form validity before proceeding.

@ryanelian
Copy link
Owner

Makes sense, sure.

I'll look into it next week (or two).

@ryanelian
Copy link
Owner

Hello,

I apologize for the very late delay. I have not found time to add your feature request due to an upcoming once-in-a-lifetime personal event.

I will be gone for another 4 weeks. I'll try to find time to add the feature after that.

@chrisdpratt
Copy link
Author

No worries. I have a workaround. It just requires persisting the validator in a global, which is kind of icky. I appreciate the effort.

@morgrowe morgrowe linked a pull request Jun 6, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants