Commit graph

21 commits

Author SHA1 Message Date
Yorhel
753cac615a Validate: Improved + extendable error message formatting
Very much needed for VNDB's advanced search validation.
Also completely undocumented.
2025-04-26 15:56:12 +02:00
Yorhel
e88ad65232 Version 0.5 2025-04-24 14:16:17 +02:00
Yorhel
8b807e6dcf Validate: Add empty() and coerce() methods
Implementing the undocumented coerce_for_json() method from TUWF and
elm_empty() from VNDB.
2025-04-19 12:36:28 +02:00
Yorhel
13661b46f9 Validate: Normalize num/int/uint to Perl numeric types + add 64bit limit to int/uint
Normalization may be undone by later validations, but this should work
in most cases.
2025-03-30 13:55:23 +02:00
Yorhel
90881924d4 Doc fixes 2025-03-21 11:31:20 +01:00
Yorhel
7c765f33bb Version 0.4 2025-03-19 10:54:23 +01:00
Yorhel
a7bfe146b1 Validate: Fix referencing & merging already compiled schemas 2025-03-17 12:50:24 +01:00
Yorhel
3382deba9a Validate: Rename "scalar" to "accept_scalar" and add "accept_array" 2025-03-16 15:39:10 +01:00
Yorhel
3fad7feec3 Validate: Rename "values"->"elems", repurpose "values" to validate hash values
I'm breaking stuff left and right while I still can.

Idea: "key_names" validation?

Idea: "tuple" validation that works like "keys" but for arrays.
  (i.e. { tuple => { $index => $schema } }, could make "missing" and
  "unknown" work for arrays, too)
2025-03-14 16:52:33 +01:00
Yorhel
fa24ca53e3 Validate: improved arrayref-schema semantics
This allows all built-in options to be duplicated inside a single
schema, the semantics of which are the same as the kind of merging
done as part of inheriting options from custom validations.

This also causes all 'keys' and 'values' validation schemas to be
merged, which changes error messages a bit but is great for
introspection. Probably slightly improves performance as well.
2025-03-14 14:28:28 +01:00
Yorhel
cea691dd55 Validate: drop creation of default values for built-ins
To better support merging multiple validations, which'll come next.
Probably.
2025-03-14 10:52:12 +01:00
Yorhel
f248a33c1c Validate: Allow multiple func validations in arrayref schema 2025-03-14 09:25:56 +01:00
Yorhel
1363e11269 Validate: allow array schemas + defer known_keys hash creation
Doesn't allow multiple 'func' options yet, needs work.
2025-03-14 07:28:11 +01:00
Yorhel
64a105e013 Validate: remove a level of indirection 2025-03-14 07:27:59 +01:00
Yorhel
9685287523 Version 0.3 2025-03-10 12:43:02 +01:00
Yorhel
e5755ddd80 Validate: Human-readable error messages 2025-03-06 10:16:14 +01:00
Yorhel
e4b6b77e1b Validate: rename rmwhitespace to trim and use builtin::trim() 2025-03-05 15:39:49 +01:00
Yorhel
cbebc3a21e Validate: Rework API, ->validate() now throws error instead of result object
This is a slight simplification and removes the need to pass around
partially normalized data. I've never found a use for the unsafe_data()
method.
2025-03-05 15:35:23 +01:00
Yorhel
3fd424c6e3 Compat fixes + 0.2 release 2025-02-28 14:05:48 +01:00
Yorhel
7b0ba45346 Docs, compatibility fixes again, 0.1 release 2025-02-25 17:02:33 +01:00
Yorhel
69262992ca FU::Validate: Add module + integrate with FU
Copied from TUWF::Validate with a few small changes. I have a few more
features planned, but let's see how this goes first.

It's been an incredibly useful module in the past, I'm not sure right
now if I had ideas for potential improvements at some point, will need
to check notes.
2025-02-25 14:31:38 +01:00