Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10352613
phone-number.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
891 B
Referenced Files
None
Subscribers
None
phone-number.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
FormControl
,
SimpleInput
}
from
"../controls/controls.js"
;
import
{
FormDataValue
}
from
"../form-types.js"
;
import
{
FormField
}
from
"./field.js"
;
export
class
PhoneNumberWithoutCountryCode
<
Required
extends
boolean
,
>
extends
FormField
<
Required
,
string
>
{
public
getEmptyValue
()
:
string
{
return
"000 000 000"
;
}
async
parse
(
ctx
:
Context
,
raw_value
:
FormDataValue
)
{
if
(
typeof
raw_value
==
"string"
)
{
return
{
parsable
:
<
const
>
true
,
parsed_value
:
raw_value
.
replaceAll
(
/[^0-9]/
,
""
)
.
replace
(
/(\d{3})(?=\d)/g
,
"$1 "
)
.
trim
(),
error
:
null
,
};
}
else
{
return
{
parsable
:
<
const
>
false
,
parsed_value
:
null
,
error
:
"Expected string"
,
};
}
}
getControl
()
:
FormControl
{
return
new
SimpleInput
(
this
,
{
inputmode
:
"tel"
,
type
:
"text"
,
placeholder
:
"123 456 789"
,
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Nov 2, 17:30 (14 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1029272
Default Alt Text
phone-number.ts (891 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment