UNPKG

fentastic

Version:

Validate and parse Forsyth-Edwards Notation (FEN) used to describe a chess game board position.

16 lines (15 loc) 413 B
export class InputError { constructor(message, argument) { this.message = message; this.argument = argument; } } export const validateInputFen = (fen) => { if (typeof fen !== 'string') { throw new InputError('FEN input must be of type \'string\'', 1); } if (!fen.length) { throw new InputError('FEN input string must not be empty', 1); } return fen; };