Wix substr is no longer work

I would like to check the email domain not in personal email,
however, value passed into onCustomValidation, endswith is not a valid funtion.

  1. I use substr, also no such function.
    Property ‘substr’ does not exist on type ‘string | boolean | File’. Property ‘substr’ does not exist on type ‘false’.
    Property ‘lastIndexOf’ does not exist on type ‘string | boolean | File’. Property ‘lastIndexOf’ does not exist on type ‘false’.

How Wix to do the String operation ?

This JavaScript method got deprecated.
Use the substring() method instead.
(ps while the second argument in the deprecated substr method was the string length, the second argument in substring method is the end index. So make the required adjustment)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

Ah, and re the endsWith method, it’s not a real problem, it’s only shown on the editor.
If you want to get rid of the the red line on the editor, do something like:

$w('#input').onCustomValidation((/** @type string */value, reject) => {
//code
})