1.1.1 • Published 7 years ago

validate-firepad-text-operation v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

validate-firepad-text-operation Build Status js-standard-style

Validate firepad text operation json

Installation

npm i --save validate-firepad-text-operation

Usage

Example 1: Successfully validate text-operation json

var validate = require('validate-firepad-text-operation')
var opJSON = [10, 'hello world', 20]

// Success
validate(opJSON)

// Go on and create a firepad TextOperation
TextOperation.fromJSON(opJSON)

Example 2: Successfully invalidate text-operation json

var validate = require('validate-firepad-text-operation')

validate({})
// throws [Error: must be an array]
validate([])
// throws [Error: operation cannot be empty]
validate(['f', 1, 1])
// throws [Error: invalid operation start]
validate([1, 1, 1, 1, 1])
// throws [Error: invalid operation middle]
validate([1, 'f', -1, -1])
// throws [Error: invalid operation end]

License

MIT