mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-22 01:02:00 -07:00
45 lines
992 B
JavaScript
45 lines
992 B
JavaScript
/*
|
|
Entry Entity
|
|
|
|
TODO: Explain what an entry is and how it works.
|
|
*/
|
|
|
|
class Entry {
|
|
validate ({
|
|
entry,
|
|
description,
|
|
slpAddress,
|
|
signature,
|
|
category
|
|
} = {}) {
|
|
// Input Validation
|
|
if (!entry || typeof entry !== 'string') {
|
|
throw new Error("Property 'entry' must be a string!")
|
|
}
|
|
if (!description || typeof description !== 'string') {
|
|
throw new Error("Property 'description' must be a string!")
|
|
}
|
|
if (!slpAddress || typeof slpAddress !== 'string') {
|
|
throw new Error("Property 'slpAddress' must be a string!")
|
|
}
|
|
if (!signature || typeof signature !== 'string') {
|
|
throw new Error("Property 'signature' must be a string!")
|
|
}
|
|
if (!category || typeof category !== 'string') {
|
|
throw new Error("Property 'category' must be a string!")
|
|
}
|
|
|
|
const entryData = {
|
|
entry,
|
|
description,
|
|
slpAddress,
|
|
signature,
|
|
category
|
|
}
|
|
|
|
return entryData
|
|
}
|
|
}
|
|
|
|
export default Entry
|