Installation
Quick Take
Idea
Traverse the string and check if all characters are suitable for 7bit encoding, in other words, are within the basic ASCII range, first 126 characters, and does not include any invisible control characters.
We don’t want any invisible control characters (anything below decimal point 32), EXCEPT:
- HT, horizontal tab, decimal number 9
- LF, new line, decimal number 10
- CR, carriage return, decimal number 13
Often decimal point 127, DEL, is overlooked, yet it is not right in your templates, especially email.
In that sense, non-ascii regex and the likes are dangerous to validate your email template code because they are too lax.
Also, we want an error reported if any lines exceed the recommended line length in email, 500 characters-per-line.
API — within()
The main function within()
is imported like this:
It’s a function which takes two input arguments:
The optional options object has the following shape:
Key | Type | Obligatory | Default | Description |
---|---|---|---|---|
lineLength Type: number Obligatory: no Default: 500 | ||||
lineLength | number | no | 500 | Max line length allowed. Set to 0 to disable. |
Here are all defaults in one place for copying:
API — defaults
You can import defaults
:
It's a plain object:
The main function calculates the options to be used by merging the options you passed with these defaults.
API — version
You can import version
: