views:

2866

answers:

4
+2  Q: 

YAML validation

Is there a website that I can upload a YAML file and check for validity? I want to be sure the data coming in will parse correctly. Is trial and error the best method?

+3  A: 

If you're using ruby, try Kwalify

here's a tutorial on YAML validation:

Kwalify YAML validation

Hope it Helps!

Pablo Fernandez
+1  A: 

Answer:

There are two basic checks you can perform: 1) a check for well-formed YAML syntax; and 2) a check for structural validity against a pre-defined data schema. The answer depends on which of these you mean in your original question.

Well-formed:

1) Can be accomplished using the normal load or parse method supplied by your language's YAML implementation. If you are not sure the syntax check will succeed, consider wrapping YAML.load() in your language's equivalent of a try/catch block.

Structurally valid:

2) Can be accomplished with a module such as Kwalify (mentioned previously). You may also search YAML.org for "validation" to see if any other similar modules have come out.

If you do not have access to a module like this, you can still do validity checking by testing the loaded variable (or data structure) using the variable-type-checking features of your programming language.

In Javascript (for example) this can be done by checking the loaded variable using the typeof() function. If your variable is complex, you may have to recursively test all branches of the complex variable using loops and branches in your code.

dreftymac
+4  A: 

Check InstantYAML. You can see the canonical YAML for your document.

+2  A: 

Use the online yaml parser

http://yaml-online-parser.appspot.com/

It can show you the output in json or a python string serialization.

Paul Tarjan