I have es6 class with constructor and validation method.
class Popups {
constructor(selector) {
this.app = selector;
}
validate() {
$.validator.addMethod('atLeastOneLowercaseLetter', (value, element) => {
return this.optional(element) || /[a-z]+/.test(value);
// how to replace `this` ??
},
'Must have at least one lowercase letter'
);
}
}
My this
refers to my Class, but I need get $.validator
with my validate form. How i can replace this?
If i write $.validator.optional(element) || /[a-z]+/.test(value)
I get error $.validator.optional is not a function