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.

How to use custom validation function from my component methods?

See original GitHub issue

Instead const mustBeCool = (value) => value.indexOf('cool') >= 0 How to call a method from component

validations: {
  gsurl: {
    this.mustBeGgl
  }
}

and

methods: {
  mustBeGgl(v) {
    return v.indexOf('google.com') >= 0		
  },
}

How?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dobromir-hristovcommented, Jan 16, 2020

That is deff not a valid object mate 😃

1reaction
dobromir-hristovcommented, Jan 16, 2020

use validations as a function

validations(){
  return {
    gsurl: { required: this.myRequiredMethod }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use Custom Form Validation in Angular - DigitalOcean
First, open your terminal and use the @angular/cli package that was installed as a dev dependency to generate a new directive: ./node_modules/@ ...
Read more >
The best way to implement custom validators - Angular inDepth
Learning best practices on how to build your custom validator in Angular by reverse engineering the built-in Angular validators.
Read more >
Adding Integrated Validation to Custom Form Controls in ...
We need to register our component with the NG_VALIDATORS provider, and implement the validate() method: The validate() method will be called ...
Read more >
Angular Custom Form Validators: Complete Guide
A validator can be plugged in directly into a reactive form simply by adding it to the validators list. Each form field has...
Read more >
Custom Form Validators • Angular - codecraft.tv
We have a few built in validators in Angular: ... We can use these in two ways: As functions we can pass to...
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