GithubHelp home page GithubHelp logo

Comments (4)

thetutlage avatar thetutlage commented on May 19, 2024

Lemme reproduce this

from indicative.

thetutlage avatar thetutlage commented on May 19, 2024

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.

easyMaxi avatar easyMaxi commented on May 19, 2024

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.

thetutlage avatar thetutlage commented on May 19, 2024

Ohh make sense that u have a size attribute. I believe custom rule will make things less complicated

from indicative.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.