index.js
function validate(json, done) {
  var log = []
  var err

  try {
    json = JSON.parse(JSON.stringify(json))
  }
  catch (e) {
    err = e
    json = {}
  }

  Object.keys(json).forEach(function (selector) {
    var declarations = json[selector]

    Object.keys(declarations).forEach(function (name) {
      var value = declarations[name]
      var result = validateItem(name, value)

      if (typeof result.value === 'number' || typeof result.value === 'string') {
        declarations[name] = result.value
      }
      else {
        delete declarations[name]
      }

      if (result.log) {
        log.push(result.log)
      }
    })
  })

  done(err, {
    jsonStyle: json,
    log: log
  })
}
function validate(json, done) {
  var log = []
  var err

  try {
    json = JSON.parse(JSON.stringify(json))
  }
  catch (e) {
    err = e
    json = {}
  }

  Object.keys(json).forEach(function (selector) {
    var declarations = json[selector]

    Object.keys(declarations).forEach(function (name) {
      var value = declarations[name]
      var result = validateItem(name, value)

      if (typeof result.value === 'number' || typeof result.value === 'string') {
        declarations[name] = result.value
      }
      else {
        delete declarations[name]
      }

      if (result.log) {
        log.push(result.log)
      }
    })
  })

  done(err, {
    jsonStyle: json,
    log: log
  })
}
function validate ( json , done ) { var log = [ ] var err try { json = JSON . parse ( JSON . stringify ( json ) ) } catch ( e ) { err = e json = { } } Object . keys ( json ) . forEach ( function ( selector ) { var declarations = json [ selector ] Object . keys ( declarations ) . forEach ( function ( name ) { var value = declarations [ name ] var result = validateItem ( name , value ) if ( typeof result . value === 'number' || typeof result . value === 'string' ) { declarations [ name ] = result . value } else { delete declarations [ name ] } if ( result . log ) { log . push ( result . log ) } } ) } ) done ( err , { jsonStyle : json , log : log } ) }
Validate a JSON Object and log errors & warnings

@param {object} json
@param {function} done which will be called with
- err:Error
- data.jsonStyle{}: `classname.propname.value`-like object
- data.log[{reason}]
Validate a JSON Object and log errors & warnings