Comments (4)
Lemme reproduce this
from indicative.
There are couple of issues here, first there is no object
rule shipped with indicative. Next size
property does not exists on a object.
You need to write custom validation rule for this, i added an example below
var objectWithLength = function (data, field, message, args) {
return new Promise(function (resolve, reject) {
var fieldValue = data[field]
/**
* skip if value does not exists, required validation
* can take care of required fields
*/
if(!fieldValue){
resolve("skipping as value does not exists")
return
}
/**
* check if value is an object
*/
if(typeof(fieldValue) === 'object') {
if(Object.keys(fieldValue) && Object.keys(fieldValue).length > 0) {
resolve("Validation passed")
return
}
}
reject(message)
})
}
indicative.extend('objectWithLength', 'Field should be a valid object', objectWithLength)
and then use it as snake_case
var rules = {
'appData.Text': 'object_with_length',
}
from indicative.
Oh, my bad!
I don't know why but i was sure there must be a object rule 💃
Thanks for the example!
But I'm not sure what you mean with size property does not exists on a object.
. size
is an attribute on my JSON object. (This is just a minimal running example and not my real JSON code, but I see no problem with a size attribute)
from indicative.
Ohh make sense that u have a size
attribute. I believe custom rule will make things less complicated
from indicative.
Related Issues (20)
- Try Catch not supported for validate method? HOT 2
- message: "lowerCase is not a sanitization method" HOT 4
- Support for stopping validation on first error per field HOT 2
- Closure messages in validation not work correctly HOT 2
- Array of strings within a nested object fails validation HOT 4
- Fail validation when no data is proved at all
- {{ argument.0 }} is returning empty
- Cannot read property 'existyStrict' of undefined
- Using Regex for email validation HOT 3
- Can I disable the nested validation?
- Error in documentation HOT 2
- Regex vaidation expect to end with $ HOT 3
- Nested field does not respect validation rules HOT 1
- Validation failed for dates with a timezone including a + (eg +02:00) HOT 1
- Need to validated empty object if empty goes to fail
- Field required but can accept empty string HOT 1
- Is this a project died? HOT 2
- Ignoring Regex to not allowing one of multiple spaces
- When a property is cast, the source object is mutated.
- npm audit report with Severity: moderate validator <=13.6.0 Inefficient Regular Expression Complexity in validator.js
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 indicative.