App-SahUtils

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN



0.483   2023-01-20  Released-By: PERLANCAR; Urgency: medium

        - Add utilities: get-value-with-sah, list-sah-value-rule-modules,
          show-sah-value-rule-modules.


0.482   2022-09-30  Released-By: PERLANCAR; Urgency: medium

        - [cli validate-with-sah] Add option --no-coerce.


0.481   2022-09-11  Released-By: PERLANCAR; Urgency: medium

        - [cli coerce-with-sah] [bugfix] Fix variable interpolation.


0.480   2022-07-16  Released-By: PERLANCAR; Urgency: medium

        - Add CLIs: list-sah-pschema-modules, list-sah-pschemas-modules.

Changes  view on Meta::CPAN

0.475   2020-02-11  Released-By: PERLANCAR; Urgency: medium

	- [filter-with-sah] Add --return-type option.


0.474   2020-02-11  Released-By: PERLANCAR; Urgency: medium

	- Add utilities: list-sah-filter-rule-modules,
	  show-sah-filter-rule-module.

	- [validate-with-sah][ux] Add -R as shortcut alias for
	  --show-raw-compile.


0.473   2020-02-10  Released-By: PERLANCAR; Urgency: medium

	- Add utility: filter-with-sah.


0.472   2019-12-25  Released-By: PERLANCAR; Urgency: low

Changes  view on Meta::CPAN

0.37    2016-07-20  Released-By: PERLANCAR

	- resolve-sah-schema: Add --return-intermediates &
	  --merge-clause-sets options.


0.36    2016-07-19  Released-By: PERLANCAR

	- Add utility: resolve-sah-schema.

	- [ux] validate-with-sah: Add shortcut options --bool, --bool-val,
	  --str-val, --full.


0.35    2016-07-01  Released-By: PERLANCAR

	- validate-with-sah: Add option --schema-module (-m) to use schema
	  from a Sah::Schema::* module.


0.34    2016-06-16  Released-By: PERLANCAR

	- Add completion for --coerce-rule, --type, & --format.

	- Add utility: format-with-sah.


Changes  view on Meta::CPAN


0.31    2016-06-12  Released-By: PERLANCAR

	- Add utility: list-sah-clauses.

	- sah-to-human: Add examples.


0.30    2016-05-30  Released-By: PERLANCAR

	- [Bugfix] validate-with-sah: setting --compiler/-C to js still set
	  compiler to perl.


0.29    2016-05-30  Released-By: PERLANCAR

        - Add scripts: list-sah-type-modules, list-sah-coerce-rule-modules.

        - coerce-with-sah: add short option alias -r for --return-type, like in
          validate-with-sah.


0.28    2016-05-25  Released-By: PERLANCAR

        - Add scripts: list-sah-schema-modules, show-sah-schema-module.


0.27    2016-05-24  Released-By: PERLANCAR

	- Adjust to Data::Sah::Coerce 0.011 (coerce_from and

Changes  view on Meta::CPAN

	  requirement.


0.14    2015-05-26  Released-By: PERLANCAR

	- Add option: --no-modules.


0.13    2015-05-22  Released-By: PERLANCAR

        - validate-with-sah: Add options --core, --core-or-pp.


0.12    2015-05-22  Released-By: PERLANCAR

        - [Bugfix] validate-with-sah: Fix Rinci metadata,
          data/multiple_data/data_file/multiple_data_file is only required when
          action=validate.


0.11    2015-05-06  Released-By: PERLANCAR

        - No functional changes.

        - Tweak Rinci metadata (fix/update args_rels metadata, dep_one ->
          dep_any).


0.10    2015-05-06  Released-By: PERLANCAR

	- Add option --hash-values to pass to compile() (Data::Sah 0.55).


0.09    2015-05-04  Released-By: PERLANCAR

	- Remove --show-human & --show-raw-human options from
	  validate-with-sah, instead a new utility is added
	  bin/sah-to-human for this (with more options).


0.08    2015-05-02  Released-By: PERLANCAR

	- Add options --show-human, --show-raw-human.


0.07    2015-05-01  Released-By: PERLANCAR

Changes  view on Meta::CPAN


        - [Incompatible change] Rename --show-linenum to --linenum,
          --show-data-with-result to --data-with-result to be more consistent
          (action options start with --show-*).

        - Add option: --pp.


0.05    2015-04-04  Released-By: PERLANCAR

	- validate-with-sah: Add options --data-file, --multiple-data-file,
          --data-file-type.

        - A couple of bug fixes.


0.04    2015-04-04  Released-By: PERLANCAR

	- [Bugfix] Typo.


0.03    2015-04-04  Released-By: PERLANCAR

	- validate-with-sah: Add options --show-raw-compile, --with-debug.


0.02    2015-04-03  Released-By: PERLANCAR

	- validate-with-sah: Add alias -r for --return-type.


0.01    2015-04-03  Released-By: PERLANCAR

        - First release.

MANIFEST  view on Meta::CPAN

script/list-sah-schemabundle-modules
script/list-sah-type-modules
script/list-sah-value-rule-modules
script/normalize-sah-schema
script/resolve-sah-schema
script/sah-to-human
script/show-sah-coerce-rule-module
script/show-sah-filter-rule-module
script/show-sah-schema-module
script/show-sah-value-rule-modules
script/validate-with-sah
t/00-compile.t
t/author-critic.t
t/author-pod-coverage.t
t/author-pod-syntax.t
t/release-rinci.t
weaver.ini

Makefile.PL  view on Meta::CPAN

    "script/list-sah-schemabundle-modules",
    "script/list-sah-type-modules",
    "script/list-sah-value-rule-modules",
    "script/normalize-sah-schema",
    "script/resolve-sah-schema",
    "script/sah-to-human",
    "script/show-sah-coerce-rule-module",
    "script/show-sah-filter-rule-module",
    "script/show-sah-schema-module",
    "script/show-sah-value-rule-modules",
    "script/validate-with-sah"
  ],
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010001",
  "NAME" => "App::SahUtils",
  "PREREQ_PM" => {
    "Complete::Module" => "0.263",
    "Complete::Util" => "0.620",
    "Data::Dump" => 0,
    "Data::Dump::Color" => "0.246",
    "Data::Sah" => "0.917",

README  view on Meta::CPAN

    22. list-sah-schemabundle-modules
    23. list-sah-type-modules
    24. list-sah-value-rule-modules
    25. normalize-sah-schema
    26. resolve-sah-schema
    27. sah-to-human
    28. show-sah-coerce-rule-module
    29. show-sah-filter-rule-module
    30. show-sah-schema-module
    31. show-sah-value-rule-modules
    32. validate-with-sah

FUNCTIONS
  get_sah_type
    Usage:

     get_sah_type(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Extract type from a Sah string or array schema.

    Uses Data::Sah::Util::Type's get_type() to extract the type name part of

lib/App/SahUtils.pm  view on Meta::CPAN

=item 27. L<sah-to-human>

=item 28. L<show-sah-coerce-rule-module>

=item 29. L<show-sah-filter-rule-module>

=item 30. L<show-sah-schema-module>

=item 31. L<show-sah-value-rule-modules>

=item 32. L<validate-with-sah>

=back

=head1 FUNCTIONS


=head2 get_sah_type

Usage:

script/coerce-with-sah  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 coerce_rules (see --coerce-rule)
 coerce_to (see --coerce-to)
 compiler (see --compiler)
 data_as_json (see --data-as-json)
 data_as_perl (see --data-as-perl)
 data_with_result (see --data-with-result)
 format (see --format)

script/filter-with-sah  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 compiler (see --compiler)
 data_as_json (see --data-as-json)
 data_as_perl (see --data-as-perl)
 data_with_result (see --data-with-result)
 filter_names (see --filter-names)
 format (see --format)
 linenum (see --linenum)

script/format-with-sah  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 compiler (see --compiler)
 data_as_json (see --data-as-json)
 data_as_perl (see --data-as-perl)
 data_with_result (see --data-with-result)
 format (see --format-arg)
 formatter_args (see --formatter-args)
 linenum (see --linenum)

script/get-value-with-sah  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 compiler (see --compiler)
 format (see --format)
 linenum (see --linenum)
 naked_res (see --naked-res)
 show_code (see --show-code)
 value_rule_names (see --value-rule-names)

script/list-sah-clauses  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 allow_expr (see --allow-expr)
 allow_expr.is (see --allow-expr-is)
 allow_expr.isnt (see --allow-expr-isnt)
 canon_name (see --canon-name)
 canon_name.contains (see --canon-name-contains)
 canon_name.in (see --canon-name-in)
 canon_name.is (see --canon-name-is)

script/list-sah-coerce-rule-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-filter-rule-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-pschema-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-pschemabundle-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-schema-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-schemabundle-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-type-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/list-sah-value-rule-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/normalize-sah-schema  view on Meta::CPAN

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-SahUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-SahUtils>.

=head1 SEE ALSO

L<validate-with-sah> can also show normalized schema using the C<--show-schema>
option.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 CONTRIBUTING


To contribute, you can send patches by email/via RT, or send pull requests on

script/resolve-sah-schema  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 allow_base_with_no_additional_clauses (see --allow-base-with-no-additional-clauses)
 format (see --format)
 merge_clause_sets (see --no-merge-clause-sets)
 naked_res (see --naked-res)
 schema (see --schema)

=head1 ENVIRONMENT

script/sah-to-human  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 format (see --format-arg)
 hash_values (see --hash-values)
 naked_res (see --naked-res)
 schema (see --schema)
 schema_file (see --schema-file)
 schema_file_type (see --schema-file-type)
 show_raw_compile (see --show-raw-compile)

script/show-sah-coerce-rule-module  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/show-sah-filter-rule-module  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/show-sah-schema-module  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/show-sah-value-rule-modules  view on Meta::CPAN

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 detail (see --detail)
 dist (see --dist)
 dist.contains (see --dist-contains)
 dist.in (see --dist-in)
 dist.is (see --dist-is)
 dist.isnt (see --dist-isnt)
 dist.max (see --dist-max)

script/validate-with-sah  view on Meta::CPAN


use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-08-06'; # DATE
our $DIST = 'App-SahUtils'; # DIST
our $VERSION = '0.485'; # VERSION

our %SPEC;

$SPEC{validate_with_sah} = {
    v => 1.1,
    summary => 'Validate data with Sah schema',
    description => <<'_',

This script is useful for testing Sah schemas. You can quickly specify from the
CLI a schema with some data to validate it against. This script can also be used
to just normalize a Sah schema and show it (`--show-schema`), or compile a
schema and show the raw compilation result (`--show-raw-compile`), or generate
validator code and show it (`--show-code`).

_
    args_rels => {
        'choose_one&' => [
            [qw/show_schema show_raw_compile show_code/],
            [qw/data multiple_data data_file multiple_data_file/],
        ],

script/validate-with-sah  view on Meta::CPAN

                },
                full => {
                    is_flag => 1,
                    summary => 'Shortcut for --return-type full',
                    code => sub { $_[0]{return_type} = 'full' },
                },
            },
            tags => ['category:validator-specification'],
        },
        show_schema => {
            summary => "Don't validate data, show normalized schema only",
            schema=>['bool', is=>1],
            cmdline_aliases => {s=>{}},
            tags => ['category:action-selection'],
        },
        show_raw_compile => {
            summary => "Don't validate data, show raw compilation result only",
            schema=>['bool', is=>1],
            cmdline_aliases => {R=>{}},
            tags => ['category:action-selection'],
        },
        show_code => {
            summary => "Don't validate data, show generated validator source code only",
            schema=>['bool', is=>1],
            cmdline_aliases => {c=>{}},
            tags => ['category:action-selection'],
        },
        data_with_result => {
            summary => "Show data alongside with validation result",
            description => <<'_',

The default is to show the validation result only.

script/validate-with-sah  view on Meta::CPAN

        },
        {
            src => q{[[prog]] -f schema1.json --multiple-data-file datafile --data-file-type json},
            src_plang => 'bash',
            summary => 'Load schema and data from file',
            test => 0,
            'x.doc.show_result' => 0,
        },
    ],
};
sub validate_with_sah {
    my %args = @_;

    my $res;
  GET_RESULT:
    {
        my $schema;
        if (defined $args{schema}) {
            if (defined $args{schema_file}) {
                $res = [400, "Please specify either 'schema' or 'schema_file', not both"];
                last GET_RESULT;

script/validate-with-sah  view on Meta::CPAN

    my $outputs_text = $args{-cmdline_r} &&
        ($args{-cmdline_r}{format} // 'text') =~ /text/;
    if ($outputs_text && $res->[0] == 200 && ref($res->[2])) {
        require Data::Dump;
        $res->[2] = Data::Dump::dump($res->[2]);
    }
    $res;
}

my $cli = Perinci::CmdLine::Any->new(
    url => '/main/validate_with_sah',
    pass_cmdline_object => 1,
    log => 1,
);
$cli->{common_opts}{naked_res}{default} = 1;
$cli->run;

# ABSTRACT: Validate data with Sah schema
# PODNAME: validate-with-sah

__END__

=pod

=encoding UTF-8

=head1 NAME

validate-with-sah - Validate data with Sah schema

=head1 VERSION

This document describes version 0.485 of validate-with-sah (from Perl distribution App-SahUtils), released on 2024-08-06.

=head1 SYNOPSIS

B<validate-with-sah> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)

B<validate-with-sah> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)

B<validate-with-sah> [B<L<--coerce|/"--no-coerce">>|B<L<--no-coerce|/"--no-coerce">>|B<L<--nocoerce|/"--no-coerce">>] [B<L<--compiler|/"--compiler=s, -C">>=I<str>|B<L<-C|/"--compiler=s, -C">>=I<str>] [(B<L<--config-path|/"--config-path=s">>=I<path>)+...



See examples in the L</EXAMPLES> section.

=head1 DESCRIPTION

This script is useful for testing Sah schemas. You can quickly specify from the
CLI a schema with some data to validate it against. This script can also be used
to just normalize a Sah schema and show it (C<--show-schema>), or compile a
schema and show the raw compilation result (C<--show-raw-compile>), or generate
validator code and show it (C<--show-code>).

=head1 OPTIONS

C<*> marks required options.

=head2 Action selection options

=over

=item B<--show-code>, B<-c>

Don't validate data, show generated validator source code only.

=item B<--show-raw-compile>, B<-R>

Don't validate data, show raw compilation result only.

=item B<--show-schema>, B<-s>

Don't validate data, show normalized schema only.

=back

=head2 Configuration options

=over

=item B<--config-path>=I<s>

Set path to configuration file.

script/validate-with-sah  view on Meta::CPAN


=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C validate-with-sah validate-with-sah

in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete validate-with-sah 'p/*/`validate-with-sah`/'

in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is also recommended to install L<shcompgen> (see above).

=head2 other shells

For fish and zsh, install L<shcompgen> as described above.

script/validate-with-sah  view on Meta::CPAN


=head2 When there is an error (e.g. in generating validator code, in validating) the program returns undef/null, how do I see the error message?

Pass `--no-naked-res` to see the error code and error message. The default is
naked for simpler output.

=head1 CONFIGURATION FILE

This script can read configuration files. Configuration files are in the format of L<IOD>, which is basically INI with some extra features.

By default, these names are searched for configuration filenames (can be changed using C<--config-path>): F</home/u1/.config/validate-with-sah.conf>, F</home/u1/validate-with-sah.conf>, or F</etc/validate-with-sah.conf>.

All found files will be read and merged.

To disable searching for configuration files, pass C<--no-config>.

You can put multiple profiles in a single file by using section names like C<[profile=SOMENAME]> or C<[SOMESECTION profile=SOMENAME]>. Those sections will only be read if you specify the matching C<--config-profile SOMENAME>.

You can also put configuration for multiple programs inside a single file, and use filter C<program=NAME> in section names, e.g. C<[program=NAME ...]> or C<[SOMESECTION program=NAME]>. The section will then only be used when the reading program match...

You can also filter a section by environment variable using the filter C<env=CONDITION> in section names. For example if you only want a section to be read if a certain environment variable is true: C<[env=SOMEVAR ...]> or C<[SOMESECTION env=SOMEVAR ...

To load and configure plugins, you can use either the C<-plugins> parameter (e.g. C<< -plugins=DumpArgs >> or C<< -plugins=DumpArgs@before_validate_args >>), or use the C<[plugin=NAME ...]> sections, for example:

 [plugin=DumpArgs]
 -event=before_validate_args
 -prio=99
 
 [plugin=Foo]
 -event=after_validate_args
 arg1=val1
 arg2=val2

 

which is equivalent to setting C<< -plugins=-DumpArgs@before_validate_args@99,-Foo@after_validate_args,arg1,val1,arg2,val2 >>.

List of available configuration parameters:

 coerce (see --no-coerce)
 compiler (see --compiler)
 core (see --core)
 core_or_pp (see --core-or-pp)
 data (see --data)
 data_file (see --data-file)
 data_file_type (see --data-file-type)

script/validate-with-sah  view on Meta::CPAN

 with_debug (see --with-debug)

=head1 ENVIRONMENT

=head2 VALIDATE_WITH_SAH_OPT

String. Specify additional command-line options.

=head1 FILES

=head2 /home/u1/.config/validate-with-sah.conf

=head2 /home/u1/validate-with-sah.conf

=head2 /etc/validate-with-sah.conf

=head1 EXAMPLES

=head2 Should succeed and return empty string

 % validate-with-sah '"int*"' 42
 
=head2 Should show an error message because "x" is not int

 % validate-with-sah '"int*"' '"x"'
 Not of type integer

=head2 Validate multiple data, should return "", 1, ""

 % validate-with-sah '["int","min",1,"max",10]' --multiple-data-json '[-4,7,15]' --return-type bool
 ["", 1, ""]

=head2 Show data alongside with result

 % validate-with-sah '["int","min",1,"max",10]' --multiple-data-json '[-4,7,15]' -d
 [
   { data => -4, result => "Must be at least 1" },
   { data => 7, result => "" },
   { data => 15, result => "Must be at most 10" },
 ]

=head2 Show validator Perl source code only, with line number

 % validate-with-sah '["int","min",1,"max",10]' -c -l
    1|do {
    2|    no warnings ('void');
    3|    require Scalar::Util::Numeric;
    4|    sub {
    5|        my ($data) = @_;
    6|        my $err_data;
    7|        my $_sahv_res = 
     |        
    9|            # skip if undef
   10|            (!defined($data) ? 1 : 

script/validate-with-sah  view on Meta::CPAN

   22|            (# clause: max
   23|            (($data <= 10) ? 1 : (($err_data //= "Must be at most 10"),0)))));
     |        
   25|        ($err_data //= "");
     |        
   27|        return($err_data);
   28|    }}

=head2 Show validator Perl source code, with no coercion code (the validator will only accept epochs)

 % validate-with-sah '["date"]' -c --no-coerce
 do {
     no warnings ('void');
     sub {
         my ($data) = @_;
         my $err_data;
         my $_sahv_res = 
         
             # skip if undef
             (!defined($data) ? 1 : 
             
             (# check type 'date'
             ((!ref($data) && $data =~ /\A[0-9]+\z/) ? 1 : (($err_data //= "Not of type date"),0))));
         
         ($err_data //= "");
         
         return($err_data);
     }}

=head2 Show validator Perl source code, with no coercion code (the validator will only accept DateTime objects)

 % validate-with-sah '["date",{"x.perl.coerce_to":"DateTime"}]' -c --no-coerce
 do {
     no warnings ('void');
     require Scalar::Util;
     sub {
         my ($data) = @_;
         my $err_data;
         my $_sahv_res = 
         
             # skip if undef
             (!defined($data) ? 1 : 

script/validate-with-sah  view on Meta::CPAN

             (# check type 'date'
             ((Scalar::Util::blessed($data) && $data->isa('DateTime')) ? 1 : (($err_data //= "Not of type date"),0))));
         
         ($err_data //= "");
         
         return($err_data);
     }}

=head2 Show validator JavaScript code

 % validate-with-sah '["int","min",1,"max",10]' -c -C js
 function(data) {
     var err_data = null;
     var tmp_data = [];
     var _sahv_res = 
     
         // skip if undef
         (!!(data === undefined || data === null) ? true : 
         
         (// check type 'int'
         ((typeof(data)=='number' && Math.round(data)==data || parseInt(data)==data) ? true : (err_data = !(err_data === undefined || err_data === null) ? err_data : "Not of type integer",0))

script/validate-with-sah  view on Meta::CPAN

         // restore original data term
         ((tmp_data).pop(), true)));
     
     err_data = !(err_data === undefined || err_data === null) ? err_data : "";
     
     return(err_data);
 }

=head2 Show validator JS source code only, with line number

 % validate-with-sah '["int","min",1,"max",10]' -C js -c -l
    1|function(data) {
    2|    var err_data = null;
    3|    var tmp_data = [];
    4|    var _sahv_res = 
     |    
    6|        // skip if undef
    7|        (!!(data === undefined || data === null) ? true : 
     |        
    9|        (// check type 'int'
   10|        ((typeof(data)=='number' && Math.round(data)==data || parseInt(data)==data) ? true : (err_data = !(err_data === undefined || err_data === null) ? err_data : "Not of type integer",0))

script/validate-with-sah  view on Meta::CPAN

   29|        // restore original data term
   30|        ((tmp_data).pop(), true)));
     |    
   32|    err_data = !(err_data === undefined || err_data === null) ? err_data : "";
     |    
   34|    return(err_data);
   35|}

=head2 Load schema from file

 % validate-with-sah -f schema1.json '["data"]'

=head2 Load schema and data from file

 % validate-with-sah -f schema1.json --multiple-data-file datafile --data-file-type json

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-SahUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-SahUtils>.

=head1 SEE ALSO

t/00-compile.t  view on Meta::CPAN

    'script/list-sah-schemabundle-modules',
    'script/list-sah-type-modules',
    'script/list-sah-value-rule-modules',
    'script/normalize-sah-schema',
    'script/resolve-sah-schema',
    'script/sah-to-human',
    'script/show-sah-coerce-rule-module',
    'script/show-sah-filter-rule-module',
    'script/show-sah-schema-module',
    'script/show-sah-value-rule-modules',
    'script/validate-with-sah'
);

# no fake home requested

my @switches = (
    -d 'blib' ? '-Mblib' : '-Ilib',
);

use File::Spec;
use IPC::Open3;

t/author-critic.t  view on Meta::CPAN

}


use strict;
use warnings;

# this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.006

use Test::Perl::Critic (-profile => "") x!! -e "";

my $filenames = ['lib/App/SahUtils.pm','script/coerce-with-sah','script/filter-with-sah','script/format-with-sah','script/get-sah-type','script/get-value-with-sah','script/is-sah-builtin-type','script/is-sah-collection-builtin-type','script/is-sah-co...
unless ($filenames && @$filenames) {
    $filenames = -d "blib" ? ["blib"] : ["lib"];
}

all_critic_ok(@$filenames);



( run in 0.719 second using v1.01-cache-2.11-cpan-a5abf4f5562 )