Test::...::Valid(3pm)
π Test::YAML::Valid β the whole vibe π
okay so bestie, welcome to Test::YAML::Valid, a little Perl module that lives inside the Test::...::Valid(3pm) manpage and exists for exactly one iconic purpose: testing whether your YAML is actually valid. no cap. it's giving "did my config file survive or did it become soup". β¨
Version: 0.04 π
β¨ SYNOPSIS β¨
the whole point of this module is making YAML validity testing stupid easy. like, look at this:
use Test::More tests => 3;
use Test::YAML::Valid;
yaml_string_ok(YAML::Dump({foo => 'bar'}), 'YAML generates good YAML?');
yaml_string_ok('this is not YAML, is it?', 'This one will fail');
yaml_file_ok('/path/to/some/YAML', '/path/to/some/YAML is YAML');
yaml_files_ok('/path/to/YAML/files/*', 'all YAML files are valid');
obsessed. π
now here's the fun part β you can also test with YAML::Syck instead of plain YAML by passing -Syck in the import list:
use Test::YAML::Valid qw(-Syck);
yaml_string_ok(...); # uses YAML::Syck::Load instead of YAML::Load
π«Ά heads up though: it's on you to make sure you actually haveYAML::Syckif you specify the-Syckoption, because it's an optional prerequisite to this module. if you request it but it's not found, a warning gets issued andYAMLis used instead. no drama, just a plot twist.
and as of version 0.04, you can use literally any module you want the same way β -Tiny for YAML::Tiny and -XS for YAML::XS. slay. π
πΈ EXPORT πΈ
here's what you get handed when you use this thing:
yaml_string_okyaml_file_okyaml_files_ok
π¦ FUNCTIONS π¦
yaml_string_ok($yaml, [$message])
the test passes if $yaml contains valid YAML (according to YAML.pm) and fails otherwise. it also returns the result of loading the YAML, which is a cute little bonus. β¨
yaml_file_ok($filename, [$message])
test passes if $filename is a valid YAML file (according to YAML.pm) and fails otherwise. returns the result of loading the YAML. π
yaml_files_ok($file_glob_string, [$message])
test passes if all files matching the glob $file_glob_string contain valid YAML. but bestie β if a file is not valid, the test fails and no further files will be examined. it just stops. done. π
returns a list of all loaded YAML.
π AUTHOR π
Jonathan Rockway, "<jrockway at cpan.org>" β the icon who made all this happen. π«Ά
π BUGS π
please report any bugs or feature requests to "bug-test-yaml-valid at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-YAML-Valid>. the way that works: I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. group chat but for bugs. π
π SUPPORT π
you can find documentation for this module with the perldoc command:
perldoc Test::YAML::Valid
you can also look for information at:
- AnnoCPAN: Annotated CPAN documentation
- CPAN Ratings
- RT: CPAN's request tracker
- Search CPAN
π ACKNOWLEDGEMENTS π
Stevan Little "<stevan.little@iinteractive.com>" contributed yaml_files_ok and some more tests. king behavior, honestly. π
β COPYRIGHT & LICENSE β
Copyright 2007 Jonathan Rockway, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page bestie!! π this was perl v5.36.0, dated 2022-11-20, living under the Test::...::Valid(3pm) manual name. go forth and validate your YAML, you absolute main character. π
β¨π
π¦ where this page comes from
- debian bookworm: libtest-yaml-valid-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-yaml-valid-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-yaml-valid-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-yaml-valid-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-yaml-valid-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms