Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

pattern not functioning as in description #12

Open
bldrvnlw opened this issue Jul 30, 2018 · 0 comments
Open

pattern not functioning as in description #12

bldrvnlw opened this issue Jul 30, 2018 · 0 comments

Comments

@bldrvnlw
Copy link

According to the README pattern does the following:

Regardless of the options allowUnknown and stripUnknown will accept keys matching the given pattern and copy their associated values over to the legalized object.

However in the code line 793 the preserved key/value pairs are placed in the value object
value[key] = val;

and then later is overwritten by validObject (line 803).

value = validObject;

Was that the intention? The preserved values are simply lost.

In addition would it make more sense to support a mode where the keys are limited to a pattern and the values are validated against a single schema? A possible notation would be to extend pattern to include a valid property that could be a schema:

object().pattern(RegExp).valid(schema)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant