Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010237
email.test.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
821 B
Referenced Files
None
Subscribers
None
email.test.ts
View Options
import
assert
from
"assert"
;
import
{
Fields
}
from
"../../index.js"
;
describe
(
"email field"
,
()
=>
{
const
ctx
=
{}
as
any
;
it
(
"validation logic"
,
async
()
=>
{
const
field
=
new
Fields
.
EmailField
(
true
);
assert
.
strictEqual
((
await
field
.
isValueValid
(
ctx
,
"yes@an.email"
)).
valid
,
true
);
assert
.
strictEqual
((
await
field
.
isValueValid
(
ctx
,
"notanemail"
)).
valid
,
false
);
});
it
(
"parse function"
,
async
()
=>
{
const
field
=
new
Fields
.
EmailField
(
true
);
const
string_response
=
await
field
.
parse
(
ctx
,
"42"
);
const
number_response
=
await
field
.
parse
(
ctx
,
42
);
assert
.
strictEqual
(
string_response
.
parsable
,
true
);
assert
.
strictEqual
(
string_response
.
parsed_value
,
"42"
);
assert
.
strictEqual
(
number_response
.
parsable
,
false
);
assert
.
strictEqual
(
number_response
.
error
,
"Please enter a string"
);
});
});
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:38 (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625348
Default Alt Text
email.test.ts (821 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment