Comments (4)
In my opinion, the static method toJSON
seems more a kind of callback that should actually be named as afterSerialize
or something like that, but, we can fall in a lot of problems dealing with this approach since it doesn't matter the feature you're gonna be dealing with the serialization will be always compromised to the behavior declared in afterSerialize
.
The second point is, it will assume that the structure
model should do more than it is proposed to do, for example, to harbor unnecessary business serialization logic.
I agree with @talyssonoc that complex serialization should live in a serializer layer and this feature will just add complexity to solve a problem more related to architectural design.
from structure.
Hello, @loweoj, sorry for the delay on answering this issue. I really like the idea, but I'm not convinced yet the name should be toJSON
since it already receives the output of the serialization 🤔, did you think of any alternative name?
from structure.
Actually, after discussing with some other contributors there are some raised concerns about it:
- Serialization is not the main goal of this lib, and in case some deeper rules for serialization are needed they should be built outside of the structure, like a
UserSerializer.serialize(userStructure)
- If we ever add this option, this should not be a static method, the idea of using a decorator is exactly to avoid polluting the class with non-business logic
- Right now our validation process depends on serialization so we can pass POJOs to Joi, this should be taken into consideration to avoid confusion during validation
After considering these points, I'm not sure anymore if we should add this feature.
from structure.
Yup makes sense. Thanks for the input guys.
from structure.
Related Issues (20)
- Nested dynamics types isn't work HOT 2
- Getters / attributes not serialized HOT 2
- Apply other validations over arrays
- problem with new js debugger vscode HOT 1
- Question: How to validate object keys?
- Schema subclass loses validate method HOT 2
- [Feature Proposal] Allow users to extend default options HOT 3
- Get other attribute value from a function called within a default value HOT 3
- Improve .eslintrc
- Add complexity checking to ESLint
- Custom validation message HOT 1
- Empty String Converted to 0 and returns Valid HOT 2
- Support Map types with itemType HOT 3
- validation for specific attribute
- custom validation HOT 1
- option to override property on validation HOT 4
- Dynamics Defaults Values aren't working HOT 1
- Method to clone an existing structure. HOT 1
- Class constructor HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from structure.