RFC: Baked-in Functions and Utilities #176
Replies: 2 comments
-
|
Thanks for this @rennokki, note that #168 introduces |
Beta Was this translation helpful? Give feedback.
-
|
This is great! Thanks for writing this up. Also worth looking at is the related docs PR - which can be previewed here. Aside from the 2 new utility functions, there are also some docs changes about the unification of resolvers with decorator values. One note - in your examples above, whenever another item is being referenced, it should be Generally I think we should copy naming where possible from excel/sheets functions, as it's fairly well known - https://formulajs.info/functions/
Some more function ideas
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have opened #172 recently, and meanwhile I am working on figuring out the whereabouts of the rest, I decided to go ahead and create this RFC to track down the ideas.
I will try to update the RFC as the discussion progresses,
strikingthe content when it gets modified.replace()/replaceAll()Performs a find-and-replace, similar to
String.replace()andString.replaceAll()in JS.Examples
Equivalent to this code:
if()Evaluating an expression to non-undefined, non-nullable, non-empty-string, adhering to JS's
Boolean()casting.Examples
Equivalent to this code:
equal(),not_equal(),gt(),gte(),lt(),lte()Here there are more proposals:
===):equal,eq,is!==):not_equal,neq,not,is_notgt/gte/lt/lteEquivalent to this code:
New type:
arraySome form of simple object, but when typed as
[...], due to limitations of envs, it will:Difference from object is that it can come with some extra functions, used before the object gets serialized (opposed to simple object):
Equivalent to this code:
Extra: Pseudo-Zod
I was thinking we could proxy the zod schema types for some envs:
This is the equivalent of this zod schema:
The overall syntax would be (formatted multiline for readability):
where:
<value type>is the type as inz.string()orz.email():string:z.string()number:z.number()boolean:z.boolean()<function=argument>is a function and its arguments following<value type>function:min=<number>:z.min(<number>)max=<number>:z.max(<number>)regex=<regex>:z.regex(<regex>)For functions that have no arguments, passing
truewould enable them, since they are optional:Beta Was this translation helpful? Give feedback.
All reactions