Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22406455
slug.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
984 B
Referenced Files
None
Subscribers
None
slug.js
View Options
const
Sealious
=
require
(
"sealious"
);
const
assert
=
require
(
"assert"
);
module
.
exports
=
app
=>
app
.
createChip
(
Sealious
.
FieldType
,
{
name
:
"slug"
,
extends
:
"text"
,
is_proper_value
:
async
(
context
,
params
,
new_value
)
=>
{
assert
.
equal
(
typeof
params
.
field_to_check
,
"string"
);
const
collection_name
=
params
.
collection_name
;
assert
.
equal
(
typeof
collection_name
,
"string"
);
// await collection.fields[params.field_to_check].is_proper_value(
// context,
// new_value
// );
if
(
params
.
include_forbidden
)
{
context
=
new
app
.
Sealious
.
SuperContext
();
}
const
matches
=
(
await
app
.
run_action
(
context
,
[
"collections"
,
collection_name
],
"show"
,
{
filter
:
{
[
params
.
field_to_check
]
:
new_value
}
}
)).
items
;
if
(
matches
.
length
)
{
return
Promise
.
reject
(
`There's already an item in
${
collection_name
}
with
${
params
.
field_to_check
}
set to
${
new_value
}
`
);
}
return
Promise
.
resolve
();
},
});
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 20:18 (4 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1229564
Default Alt Text
slug.js (984 B)
Attached To
Mode
rSEALPAGE Sealpage
Attached
Detach File
Event Timeline