Comments (4)
+1, would love to know if this is in the future of Obey.js
from obey.
Just found https://github.com/node-modli/modli created by the same maintainers as Obey
from obey.
There isn't any built-in way to do this as it stands, however, as @ummjackson shared, Modli (built by our team) is a full CRUD solution which extends on Obey to allow for doing things like this.
Given getFullName
is more a function of a data read action, and not so much one of validation, I would see it better placed outside the scope of Obey. You could do something as simple as:
const user = {
schema: obey.model({
fname: { type: 'string' },
lname: { type: 'string' }
}),
getFullName: (data) => {
return data.fname + ' ' + data.lname
},
read: () => {
return db.read({...})
}
/* ...other custom methods... */
}
The above is essentially what Modli does, just creating a model object with other methods associated, then on create
and update
we just run the data through the schema
's validate
method beforehand.
from obey.
I'm willing to reopen this if there's a sound argument for including this functionality, or simply to discuss further. However, for now I'm going to close it.
from obey.
Related Issues (20)
- read-only field as an option HOT 3
- Documentation Generator
- Types: array, allow empty HOT 1
- Conditional Requires
- Error for requireIf/requireIfNot related defaults, creators
- New feature request: "equalsTo" validator HOT 3
- initData is not updated HOT 3
- (breaking) change `requireIf`(Not) to `requiredIf`(Not) HOT 1
- Return array data correctly if no `values` specified HOT 1
- 'default' validator doesn't work for booleans
- allowNull: true/default: null overridden if initial val is falsey (but not null)
- Predefined types allow empties without running type validations
- Error messages for invalid nested arrays/objects are useless
- Account for dynamic keys in nested conditional requires
- Using `allow` with `empty` is broken for strings
- Non-string zip codes with leading 0 invalid
- Null value fails with allowNull and no default
- Creators/modifiers that return null values fail with allowNull
- Conditional requires in arrays of objects
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 obey.