package Data::Sah::Coerce::perl::To_array::From_str::comma_sep;

our $DATE = '2021-04-08'; # DATE
our $DIST = 'Data-Sah-CoerceBundle-To_array-From_str-comma_sep'; # DIST
our $VERSION = '0.013'; # VERSION

use 5.010001;
use strict;
use warnings;

sub meta {
        v => 4,
        summary => 'Coerce array from a comma-separated items in a string',
        prio => 60, # a bit lower than normal
        args => {
            separator => {
                schema => ['str*', min_len=>1],
                default => ',',
            # TODO: separators

sub coerce {
    my %cargs = @_;

    my $dt = $cargs{data_term};
    my $gen_args = $cargs{args};

    my $res = {};

    $res->{expr_match} = "!ref($dt)";

    my $sep = $gen_args->{separator} // ',';
    $res->{expr_coerce} = "[split /\\s*\Q$sep\E\\s*/, $dt]";


# ABSTRACT: Coerce array from a comma-separated items in a string



=encoding UTF-8

=head1 NAME

Data::Sah::Coerce::perl::To_array::From_str::comma_sep - Coerce array from a comma-separated items in a string

=head1 VERSION

This document describes version 0.013 of Data::Sah::Coerce::perl::To_array::From_str::comma_sep (from Perl distribution Data-Sah-CoerceBundle-To_array-From_str-comma_sep), released on 2021-04-08.


To use in a Sah schema:


=for Pod::Coverage ^(meta|coerce)$


Please visit the project's homepage at L<>.

=head1 SOURCE

Source repository is at L<>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<>

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired

=head1 SEE ALSO

L<Data::Sah::Coerce::perl::To_array::From_str::csv_row> can accomplish the same
thing, with additional ability to handle escapes and quotes.


=head1 AUTHOR

perlancar <>


This software is copyright (c) 2021, 2020, 2019, 2018, 2016 by

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.