Discuss Scratch

nXIII
Scratcher
1000+ posts

SB2 Validator

SB2 Validator
A web app to help debug tools that output Scratch files. Get it here.

It currently supports .sb2 project files and .json project info files (support for sprite files is forthcoming). Drag and drop files anywhere onto the page or click to select a file from your computer. The validator will show “Valid” if the file conforms to the most recent Scratch file format, or show “Failed!” with error details if the file does not conform.

Note: The validator is very strict. Even if a file can be read by Scratch, it may not validate—files must closely match Scratch's own format, and include most of the information that Scratch includes in its own project files. This is to establish a minimum set of properties that programs can expect to see in Scratch files.

Extensions
The validator does not allow arbitrary properties in project.json files that Scratch does not use. However, it does allow extension properties beginning with x_. This helps other programs include additional information and metadata in a project file while avoiding future name conflicts with Scratch's properties. For example:
{
    // ...
    "info": {
        "hasCloudData": false,
        "videoOn": false,
        // ...
        "x_generator": "Awesome Scratch Compiler",
        "x_version": "2.1",
        "x_projectProperties": {
            "language": "JavaScript"
        }
    }
}

Browser Support
It works on the stable branches of Chrome, Firefox, and Safari. I only test Chrome regularly, so let me know if it stops working in any of those browsers.

Bugs
It has 'em. Please report any bugs you find on this thread, with (1) a link to a project which exhibits this bug and (2) a short description of the bug. See the bottom of this post for a list of known bugs.

Source Code
SB2 Validator is written in CoffeeScript. You can get the source (and license) on the Github repo.

Specification
There's no specification for the Scratch project file format, but SB2 Validator is written in a declarative style so it's easy to understand the format of project files. The declaration of window.schema (search for “@schema = ” in validate/index.coffee) is a readable description of the objects and types in the file format.

Last edited by nXIII (Dec. 19, 2013 22:02:00)

blob8108
Scratcher
1000+ posts

SB2 Validator

Bug: it doesn't recognise the “backgroundIndex” property for block watchers. project
nXIII
Scratcher
1000+ posts

SB2 Validator

blob8108 wrote:

Bug: it doesn't recognise the “backgroundIndex” property for block watchers. project
Thanks—fixed. That link is broken, but I tested it with a different project.
blob8108
Scratcher
1000+ posts

SB2 Validator

nXIII wrote:

That link is broken, but I tested it with a different project.
Dropbox lied to me! Cool, thanks.
nXIII
Scratcher
1000+ posts

SB2 Validator

Updated the list of menu names (removed some obsolete ones).
nXIII
Scratcher
1000+ posts

SB2 Validator

SB2 validator is now on Github! It has a nicer, shorter URL too: http://nathan.github.io/sb2/validate/
drmcw
Scratcher
1000+ posts

SB2 Validator

Error messages are somewhat unfriendly;

Failed!
Expected (one of at “scripts 0.2.2.1”) or undefined at “scripts”

?
nXIII
Scratcher
1000+ posts

SB2 Validator

drmcw wrote:

Error messages are somewhat unfriendly;

Failed!
Expected (one of [all, this script, other scripts in sprite] at “scripts 0.2.2.1”) or undefined at “scripts”
The things in quotes show the key path and the things in brackets show the valid options. Could you share the project file that you were trying to validate?
drmcw
Scratcher
1000+ posts

SB2 Validator

nXIII wrote:

drmcw wrote:

Error messages are somewhat unfriendly;

Failed!
Expected (one of [all, this script, other scripts in sprite] at “scripts 0.2.2.1”) or undefined at “scripts”
The things in quotes show the key path and the things in brackets show the valid options. Could you share the project file that you were trying to validate?

It was Griffpatch's Scratchnapped project!

Because I was pretty sure it would fail

Last edited by drmcw (Dec. 19, 2013 22:32:52)

nXIII
Scratcher
1000+ posts

SB2 Validator

drmcw wrote:

It was Griffpatch's Scratchnapped project!
Thanks for reporting that bug! I also found and fixed another one using the same project, and it now validates for me.
drmcw
Scratcher
1000+ posts

SB2 Validator

No problem. The reason I expected the validator to fail and still do for Scrathnapped is because in the monster sprite, on the when I receive Head Pound 2, in change variable yyy by chgY. the chgY looks like a parameter but it's not in a define block. Surely that should flag an error?
nXIII
Scratcher
1000+ posts

SB2 Validator

drmcw wrote:

No problem. The reason I expected the validator to fail and still do for Scrathnapped is because in the monster sprite, on the when I receive Head Pound 2, in change variable yyy by chgY. the chgY looks like a parameter but it's not in a define block. Surely that should flag an error?
Yeah—I'm not doing a lot of semantic checking on the scripts right now, but that would be a useful error to throw.
drmcw
Scratcher
1000+ posts

SB2 Validator

If you want another nice one see this project. If you look at the latest comments I think they explain the issues. Hopefully they haven't been fixed especially the “undefined” block which I understand is left in on purpose if the ST wanted to see it.
k9lego
Scratcher
1000+ posts

SB2 Validator

What's wrong with the ability to make changes (variable lists, etc.) to custom blocks? k9lego
nXIII
Scratcher
1000+ posts

SB2 Validator

k9lego wrote:

What's wrong with the ability to make changes (variable lists, etc.) to custom blocks?
Sorry, I'm not sure I understand what you're asking.
k9lego
Scratcher
1000+ posts

SB2 Validator

nXIII wrote:

k9lego wrote:

What's wrong with the ability to make changes (variable lists, etc.) to custom blocks?
Sorry, I'm not sure I understand what you're asking.
One of the features I like in scratch is the ability to create those. k9lego.
drmcw
Scratcher
1000+ posts

SB2 Validator

k9lego wrote:

nXIII wrote:

k9lego wrote:

What's wrong with the ability to make changes (variable lists, etc.) to custom blocks?
Sorry, I'm not sure I understand what you're asking.
One of the features I like in scratch is the ability to create those. k9lego.

Did anyone say it was wrong? If you think that was what was in scratchnapped then it isn't. It is in fact a bug. See this for an example.

Last edited by drmcw (Dec. 28, 2013 09:48:22)

AxNoodle
Scratcher
2 posts

SB2 Validator

The validator says:
Expected (((_mouse_at“childeren.0.scripts.0.2.1.1”)or(sprite name at “childeren.0.scripts.0.2.1.1”)at“childeren.0.scripts.0.2.1.1”)or undefined at“childeren.0.scripts”) or (string at “childeren.0.target”)or (string at“childeren.0.listName”)at“childeren.0”

What is wrong?
HenWiii
Scratcher
13 posts

SB2 Validator

The validator says:

Expected string at “objName”

Can you tell me what went wrong?
Here's the sb2: Waluigi pinball v2.0.sb2

Powered by DjangoBB