Sah::S...on_meta(3pm)

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

πŸ’– NAME πŸ’–

Sah::Schema::rinci::function_meta β€” ok bestie, this is the Rinci function metadata schema, and it's lowkey the main character of this whole page. ✨

This page is your girl Sah::S...on_meta(3pm), she's a little shy about her full name in the header but we know who she is 🫢


🌸 VERSION 🌸

This doc describes version 1.1.98.0 of Sah::Schema::rinci::function_meta (she ships in the Perl distribution Sah-Schemas-Rinci), and she was released on 2021-07-20. Time flies fr fr πŸ¦‹


✨ SYNOPSIS ✨

πŸ’… Wanna check your data against this schema? (needs Data::Sah)

use Data::Sah qw(gen_validator);
my $validator = gen_validator("rinci::function_meta*");
say $validator->($data) ? "valid" : "INVALID!";

# Data::Sah can also create validator that returns nice error message string
# and/or coerced value. Data::Sah can even create validator that targets other
# language, like JavaScript. All from the same schema. See its documentation
# for more details.

Not me obsessed with one schema doing all that. One schema, many validators, other languages?? It's giving ✨multilingual icon✨ iykyk πŸ’–

πŸŽ€ Wanna validate function parameters against this schema? (needs Params::Sah)

use Params::Sah qw(gen_validator);

sub myfunc {
    my @args = @_;
    state $validator = gen_validator("rinci::function_meta*");
    $validator->(\@args);
    ...
}

state $validator staying cached across calls is the moment, honestly. Efficiency queen πŸ‘‘

🌈 Wanna put this schema inside Rinci function metadata and let Perinci::CmdLine build you a CLI?

Say less:

# in lib/MyApp.pm
package
  MyApp;
our %SPEC;
$SPEC{myfunc} = {
    v => 1.1,
    summary => 'Routine to do blah ...',
    args => {
        arg1 => {
            summary => 'The blah blah argument',
            schema => ['rinci::function_meta*'],
        },
        ...
    },
};
sub myfunc {
    my %args = @_;
    ...
}
1;

# in myapp.pl
package
  main;
use Perinci::CmdLine::Any;
Perinci::CmdLine::Any->new(url=>'MyApp::myfunc')->run;

# in command-line
% ./myapp.pl --help
myapp - Routine to do blah ...
...

% ./myapp.pl --version

% ./myapp.pl --arg1 ...

Metadata in, whole CLI out. That's the pipeline, bestie, and it ate πŸ”₯

πŸ“ Sample data (vibe check βœ…)

{}  # valid

{args=>{a1=>{},a2=>{}},summary=>"Some function",v=>1.1}  # valid

Both valid!! Empty hash? valid. Full-on function metadata with args, summary and v? Also valid. Versatile πŸ’œ


🌐 HOMEPAGE 🌐

Go visit the project's homepage, it's right here: <https://metacpan.org/release/Sah-Schemas-Rinci>. Do it for her πŸ₯Ί


πŸ“¦ SOURCE πŸ“¦

The source repo lives at <https://github.com/perlancar/perl-Sah-Schemas-Rinci>. Come through, the code is right there 🫢


πŸ› BUGS πŸ›

Found a bug? Got a feature request? Please report it on the bugtracker website: <https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Rinci>

And listen bestie, when you submit a bug or a request, please include a test-file β€” or a patch to an existing test-file β€” that shows off the bug or the feature you want. No test file = the maintainers are just guessing at your vibe, and that's not the move 😭

πŸ‘‘ AUTHOR πŸ‘‘

perlancar <perlancar@cpan.org> β€” the actual legend behind all of this πŸ’–


This software is copyright (c) 2021, 2020, 2019, 2018, 2016 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free software, free to share, iconic behavior periodt πŸ’…


Okay that's the whole page, we made it!! 🌟 This was rendered by perl v5.36.0 on 2022-11-19, and this little manpage name is Sah::S...on_meta(3pm) in case you ever need to find her again. Byeee, go validate something πŸ¦‹πŸ’–

πŸ“¦ where this page comes from