Test::...::Valid(3pm)

πŸ“¦
version 0.04 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 have YAML::Syck if you specify the -Syck option, because it's an optional prerequisite to this module. if you request it but it's not found, a warning gets issued and YAML is 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_ok
  • yaml_file_ok
  • yaml_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:


🌈 ACKNOWLEDGEMENTS 🌈

Stevan Little "<stevan.little@iinteractive.com>" contributed yaml_files_ok and some more tests. king behavior, honestly. πŸ‘‘


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