Dictionary module
Generic procs to interface with the database/dictionary. Validates characters and replaces malicious ones (< and >).
Types
SubmitRequest = object
ValidationResponse = tuple[success: bool, details: string]
Consts
replaceCharacters: seq[array[2, string]] = [["<", "<"], [">", ">"]]
- Suspicious characters with their not-sus counterparts
Procs
proc constructHash(word, definition: string): string {....raises: [], tags: [], forbids: [].}
- Constructs a hash for a definition
proc replaceAllSussyCharacters(decoded: string): string {....raises: [], tags: [], forbids: [].}
- Replaces all sus characters using replaceCharacters
proc replaceAllSussyCharactersDecodeEncode(encoded: string): string {. ...raises: [], tags: [], forbids: [].}
-
Replaces all sus characters using replaceCharacters
Input is an encoded url string, which is also returned after completion
proc validateNewEntryAndCommit(word, definition, author: string): Future[ ValidationResponse] {....stackTrace: false, raises: [Exception, ValueError], tags: [ DbEffect, ReadDbEffect, WriteDbEffect, RootEffect], forbids: [].}
-
Validates, replaces sussy characters and finally commits new definition to the database if:
- hash is not known
- non-optional fields are not empty