You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
'appData.Text': 'object', 'appData.Text.size': 'required_if:appData.Text|integer',
is my schema.
Am I wrong at using the module this way? My idea is to check if appData.Text is there and an object. If it's an object I need the size attribute.
Error: Trying to redefine 'Text' which is a string at DotObject._fill (\node_modules\indicative\node_modules\dot-object\index.js:73:15) at DotObject._fill (\node_modules\indicative\node_modules\dot-object\index.js:79:10) at \node_modules\indicative\node_modules\dot-object\index.js:96:12 at Array.forEach (native) at DotObject.object (\node_modules\indicative\node_modules\dot-object\index.js:92:20) at Function.<anonymous> (\node_modules\indicative\node_modules\dot-object\index.js:59:31) at Validator.validate (\node_modules\indicative\lib\validator.js:133:11)
Beside this: Thanks for the module!
EDIT:
Ok, I could ask for appData.Text.size. This implicit appData.Text is a object.
Seams like a legit workaround for my case.
The text was updated successfully, but these errors were encountered:
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
varobjectWithLength=function(data,field,message,args){returnnewPromise(function(resolve,reject){varfieldValue=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)
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)
'appData.Text': 'object', 'appData.Text.size': 'required_if:appData.Text|integer',
is my schema.
Am I wrong at using the module this way? My idea is to check if appData.Text is there and an object. If it's an object I need the size attribute.
Error: Trying to redefine 'Text' which is a string at DotObject._fill (\node_modules\indicative\node_modules\dot-object\index.js:73:15) at DotObject._fill (\node_modules\indicative\node_modules\dot-object\index.js:79:10) at \node_modules\indicative\node_modules\dot-object\index.js:96:12 at Array.forEach (native) at DotObject.object (\node_modules\indicative\node_modules\dot-object\index.js:92:20) at Function.<anonymous> (\node_modules\indicative\node_modules\dot-object\index.js:59:31) at Validator.validate (\node_modules\indicative\lib\validator.js:133:11)
Beside this: Thanks for the module!
EDIT:
Ok, I could ask for appData.Text.size. This implicit appData.Text is a object.
Seams like a legit workaround for my case.
The text was updated successfully, but these errors were encountered: