The YAML spec is pretty complicated, and has alot of edge cases. If your whole document is
---
gjsogjsgj:gsdgs:sgdjsjgosdg:
That's actually valid YAML. In some examples like:
---
thing1
thing2
thing3:
The YAML isn't invalid until it hits line 4. Without the last colon, that would be valid YAML.
Here's the spec (it's a heavy read): http://www.yaml.org/spec/1.2/spec.html
And here's a convenient way to check out some YAML examples: http://www.yamllint.com/