Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F4637607
regexp.test.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
914 B
Referenced Files
None
Subscribers
None
regexp.test.ts
View Options
import
assert
from
"assert"
;
import
{
Fields
}
from
"../../index.js"
;
describe
(
"regexp field"
,
()
=>
{
const
ctx
=
{}
as
any
;
it
(
"validation logic"
,
async
()
=>
{
const
field
=
new
Fields
.
RegExpField
(
true
,
/^4/
,
"error"
);
assert
.
strictEqual
((
await
field
.
isValueValid
(
ctx
,
"42"
)).
valid
,
true
);
assert
.
strictEqual
((
await
field
.
isValueValid
(
ctx
,
"notvalid"
)).
valid
,
false
);
assert
.
strictEqual
((
await
field
.
isValueValid
(
ctx
,
42
)).
valid
,
false
);
});
it
(
"parse function"
,
async
()
=>
{
const
field
=
new
Fields
.
RegExpField
(
true
,
/^4/
,
"error"
);
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
Tue, May 27, 23:48 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
624791
Default Alt Text
regexp.test.ts (914 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment