-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PE-6941 add description and keywords #25
Conversation
README.md
Outdated
| Tag Name | Type | Pattern | Required | Description | | ||
| ----------- | ------ | ----------------- | -------- | --------------------------------- | | ||
| Action | string | "Set-Description" | true | Action tag for triggering handler | | ||
| Description | string | N/A | true | New description for ANT. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pattern is 512 characters. Could specify utf-8 only but the limit is probably fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 512 character pattern.
README.md
Outdated
| Tag Name | Type | Pattern | Required | Description | | ||
| -------- | ------ | -------------- | -------- | --------------------------------- | | ||
| Action | string | "Set-Keywords" | true | Action tag for triggering handler | | ||
| Keywords | table | "^[%w-_]+$" | true | New keywords for ANT. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Keywords | table | "^[%w-_]+$" | true | New keywords for ANT. | | |
| Keywords | table | "^[%w-_]{1,32}$" | true | New keywords for ANT. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider allowing special characters - could allow integrations with apps that use # and @ for pointing to specific topics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added # and @.
|
||
#### `Set-Keywords` | ||
|
||
Sets the keywords for the ANT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth mentioned max table size of 16 and min of 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to include that detail.
src/common/balances.lua
Outdated
|
||
function balances.setKeywords(keywords) | ||
assert(type(keywords) == "table", "Keywords must be an array") | ||
assert(#keywords <= 16, "There must not be more than 16 keywords") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend add a check for the table containing atleast 1 keyword
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if they want to empty their keywords?
src/common/initialize.lua
Outdated
assert(type(keywords) == "table", "Keywords must be an array") | ||
assert(#keywords <= 16, "There must not be more than 16 keywords") | ||
|
||
local seenKeywords = {} | ||
for _, keyword in ipairs(keywords) do | ||
assert(type(keyword) == "string", "Each keyword must be a string") | ||
assert(#keyword <= 32, "Each keyword must not be longer than 32 characters") | ||
assert(not keyword:find("%s"), "Keywords must not contain spaces") | ||
assert(keyword:match("^[%w-_]+$"), "Keywords must only contain alphanumeric characters, dashes, or underscores") | ||
assert(not seenKeywords[keyword], "Duplicate keyword detected: " .. keyword) | ||
seenKeywords[keyword] = true | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is all duplicate code, recommend pulling this out into a validation util and using here as well as in the setKeyword util
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point. Added utility function to validate keywords.
1585978
to
be0b48f
Compare
No description provided.