Combined refine/transform
See original GitHub issueHello,
I’m using transform()
to base64-decode a value. I’m bumping up against this requirement from the docs:
⚠️ Transformation functions must not throw. Make sure to use refinements before the transformer to make sure the input can be parsed by the transformer.
To satisfy this requirement, I am doing this:
const schema = string().refine(isBase64).transform(d => Buffer.from(d, 'base64'));
function isBase64(data: string): boolean {
try {
Buffer.from(data, 'base64');
} catch {
return false;
}
return true;
}
This implementation is a little silly since I am base64-decoding the object just to check whether I can base64-decode it.
Is there some way to memoize the Buffer
object created in refine
call, so that I don’t have to double-decode?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Grid Manipulations (merge, split, refine, transform) - pygridtools
Most grid transformations such as merge and transpose return a new object, allowing consecutive operations to be chained together. Optionally, you can pass ......
Read more >Data Transformation with OpenRefine - Web Scraper
It takes data from a column and clusters it allowing the user to bundle possibly-similar groups together. For example, if there are many ......
Read more >@enlight.refine.transform • Instagram photos and videos
Though we journey together, our paths are different, our timing is different, but · God will give you vision and instruct you to...
Read more >Add Refine transform function for Netflow data set (I6a24d41e ...
Add Refine transform function for Netflow data set This change adds a new file with a Refine ... Change has been successfully merged...
Read more >Common Transformations - OpenRefine
Common Transformations · Removing Duplicates · Splitting Cell Values · Combining Cell Values · Data Shaping · Clustering.
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
This is a known limitation. Refinements and transforms will be combined into a single concept at some point in the near future. I’ll post here when that happens. 👍
should we keep this open? it’s a very common use case.