This is designed as a validator designed around current Arena standards -- to be used to validate and confirm whether or not a platform's generated export format meets Arena's specs (as Arena has no officially published specs, I've tried to determine varied test cases including decks with both commanders and companions).
- There are four possible sections, that appear in the following sequence: Commander, Companion, Deck, Sideboard.
- The section title is the first line of each section.
- Blank lines are inserted after each section.
- If a line begins with an integer, it's a card. If it begins with anything else, it's a Section title.
- The Commander section, if included, contains a single card, and that card resides ONLY in the Commander section.
- The Companion section, if included, contains a single card, and that card is DUPLICATED and also is included in the Sideboard section.
- The Deck is required. You can't have a deck without a deck.
- The Sideboard section is optional, UNLESS your deck is using a Companion. If using a Companion, at least one copy of the Companion must also be included in the Sideboard.
- Card lines are formatted as follows:
[qty] [name] ([set]) [collectors number]
and can be matched via the following regex:/^\d+ .+ \([\dA-Z]{3}\) \d+$/i
The main purpose for this gist is to provide a consistent test that multiple providers and sites can all build to, to ensure their output validates.
To that end, it's built in Javascript, so that it can more easily be used on any platform, regardless of the server-side language.