3.1.1 • Public • Published


Validate a tournament bracket.

NPM Build Status Greenkeeper badge

To see the data this repo is built on, check out bracket-data.

What is this?

bracket-validator is a module that takes a string representation of a bracket and validates it against the real data for that bracket's sport and year.

The main use case for this is to validate a user's entry against the actual data in order to score it or display it showing correct/incorrect picks. There are other modules which rely on bracket-validator such as bracket-scorer and bracket-updater.

API / Usage

Make a new bracket-validator object with an options object (the year and sport options are required and passed directly to bracket-data):

var BracketValidator = require('bracket-validator');
var validator = new BracketValidator({
   year: '2013',
   sport: 'ncaam',
   /* User bracket string */


  • sport: The sport you are validating. See bracket-data for more info.
  • year: The year you are validating. See bracket-data for more info.
  • testOnly: (Boolean, default: false) Whether to only test the validation and not return an expanded bracket
  • allowEmpty: (Boolean, default: true) Whether the validation should allow unpicked matches. This is useful for validating a bracket as a user is selecting it.
  • flatBracket: (String, default: '') The user's bracket to validate


  • validate(flatBracket): Validate the bracket. The param flatBracket is optional here. If you pass it in, it will call reset first and then validate, otherwise it will use the option it was instantiated with. It will return one of the following:
    • An Error with the message set to why the validation failed
    • The flatBracket if validation is successfull and testOnly is set to true
    • An expanded bracket object created from flatBracket if validation is successful. It will have each region containing a multidimensional array: rounds. This is ordered by round and picks, where if a pick is made it will contain the team seed and name and if a pick is not made it will be null.
  • reset(flatBracket): Reset the validator to use a new flatBracket.

Anything else?

If this is interesting to you, I think you should follow me (@lukekarrys) and @tweetthebracket on Twitter. There are also a lot of other bracket related modules on our GitHub organization page.

Package Sidebar


npm i bracket-validator

Weekly Downloads






Unpacked Size

36 kB

Total Files


Last publish


  • lukekarrys