Missing attributes during conversion using an ActionFunction with morphism()
See original GitHub issueIf I have a definition such as:
interface Grade = {
level: 'A'|'B'|'C'
note?: string
}
interface Student = {
name: string
grade?: Grade
}
interface StudentDocument = {
name: string,
grade_data?: {
level: 'A'|'B'|'C'
note?: string
}
}
const gradeSchema: StrictSchema<Grade> = {
level: 'level',
note: 'note'
}
const studentSchema: StrictSchema<Student, StudentDocument> = {
name: 'name',
grade: ({ grade_data }: any) => morphism(gradeSchema, grade_data),
}
Then the following function call will give:
morphism(studentSchema, { name: 'John Doe' })
{ name: 'John Doe',
grade: [Function] }
I can wrap this in something like:
grade: ({ grade_data }: any) => grade_data ? morphism(gradeSchema, grade_data) : null
However it would be nice if the morphism never resulted in a function even with missing values. What is the strategy when working with optional values?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Unable to pass parameter using Action Function
I'm missing the name attribute while using the apex:param tag.So that i s causing the problem. Although i'm not sure why we require...
Read more >actionFunction working only when I have certain parameters ...
I am having a weird issue when using apex:actionFunction as it only works sometimes (Only when I am passing a parameter in the...
Read more >Part III Profinite Groups - DPMMS
One group that obviously satisfies the properties of Z in the above diagram is G itself. So there is a natural homomorphism ι:...
Read more >Notes on Computational Group heory
to construct these groups and determine their properties. ... a differential equation, in the same way as she would use Maple to solve...
Read more >F# for Fun and Profit
Other interesting ways of using F# at work ... mindset, and not realize what you are missing. ... let nextLineFn = fun() ->...
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 Free
Top 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
@terlar Thank you for your feedback !I did release a new version 1.10 with which it is possible to either strip the key when the value is undefined or provide a default value to replace undefined ones.
To do so it is now possible to create a schema with options using the
createSchema
function.Strip undefined value
Default value fallback
Here’s a playground if you want to see it working: https://repl.it/@yrnd1/Morphism-undefined-values
Please let me know what you think about it and don’t hesitate if you have questions 😃
Sorry for the delay, I didn’t have time to update my implementation to use this until now. Just want to return here to say thank you and I am very satisfied with the current behavior. Keep up the good work 👍