*Question* Is it possible to apply "strict" mode to avoid coercing data types, but still allowing transforming?
See original GitHub issueI have an API that receives different fields, one of which would be a zipcode-like document. Normally, users can send documents with punctuation, like dashes and commas, and I’d like to:
- Not allow any values that aren’t strings (example: Yup coerces
[1,2]
into12
in non strict mode) - Remove non digits from the text (I used
transform()
to change1.2.3
into123
, for example).
However, it seems strict mode only allows one or the other, never both.
I can think of solutions involving the test()
method, but just to make sure I’m not missing out on any features, is it feasible without using test()
?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Strict mode - JavaScript - MDN Web Docs
JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode".
Read more >about "strict" mode - SQLite Forum
A strict setting is stored in each database file, and is set like PRAGMA page_size . To convert an existing database to strict...
Read more >Reasons for choosing not to use strict mode? : r/PHP - Reddit
Avoiding strict types in PHP because coercion at language runtime boundaries where type metadata is implicitly missing is a pretty weak reason, ...
Read more >What is "strict mode" and how is it used? - Stack Overflow
Strict mode is a new feature in ECMAScript 5 that allows Developers to put the code inside the "strict" context. This strict context...
Read more >Strict mode - Ajv JSON schema validator
Strict mode intends to prevent any unexpected behaviours or silently ignored mistakes in user schemas. It does not change any validation results compared ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There isn’t a built in way, but you can build your own string schema that does it.
Great! It worked! Thanks for the help @jquense