Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10352609
color.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
855 B
Referenced Files
None
Subscribers
None
color.ts
View Options
import
{
is
,
predicates
}
from
"@sealcode/ts-predicates"
;
import
{
JDDContext
}
from
"../index.js"
;
import
{
StringBasedArgument
}
from
"./string-based-argument.js"
;
export
class
Color
extends
StringBasedArgument
<
string
>
{
example_values
=
[
"#aa00cc"
,
"#000000"
,
"#ffffff"
];
getTypeName
()
{
return
"Color"
;
}
constructor
()
{
super
();
}
getEmptyValue
()
{
return
"#000000"
;
}
countWords
(
_ctx
:
JDDContext
,
value
:
string
)
:
number
{
return
value
.
toString
().
split
(
" "
).
length
;
}
async
receivedToParsed
(
_
:
JDDContext
,
value
:
string
)
:
Promise
<
string
>
{
if
(
is
(
value
,
predicates
.
string
))
{
let
regex
=
new
RegExp
(
"^#[0-9a-f]{6}$"
);
if
(
regex
.
test
(
value
))
{
return
value
;
}
regex
=
new
RegExp
(
"^#[0-9a-f]{3}$"
);
if
(
regex
.
test
(
value
))
{
return
value
;
}
return
"#000000"
;
}
else
{
return
"#000000"
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Nov 2, 17:29 (14 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1030459
Default Alt Text
color.ts (855 B)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment