8000 GitHub - remko/ajv-content-encoding: Plugin to validate strings with `contentEncoding` in AJV
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

remko/ajv-content-encoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ajv-content-encoding: Plugin for contentEncoding validation in AJV

Adds support to AJV for validating strings with contentEncoding.

Supports the types defined in RFC2045: base64, 7bit, 8bit, binary, and quoted-printable.

Install

yarn add ajv-content-encoding

or

npm install ajv-content-encoding

Usage

const Ajv = require('ajv');
const ajv = require('ajv-content-encoding')(new Ajv());

const validate = ajv.compile({
  type: "string",
  contentEncoding: "base64"
});

validate("aGVsbG8K"); // true
validate("invalid"); // false

Caveats

  • The values of contentEncoding should be all-lowercase, and are case-sensitive (i.e. base64, 7bit, 8bit, binary, and quoted-printable).
  • The quoted-printable validation does not validate all constraints on quoted-printable encodings. E.g., it is more forgiving in when to allow newline characters etc.

About

Plugin to validate strings with `contentEncoding` in AJV

Resources

Stars

Watchers

Forks

Packages

No packages published
0