Skip to content

Commit

Permalink
fix style for #100
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Nov 6, 2015
1 parent 4b546a6 commit 851d3cc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,16 @@ var compile = function(schema, cache, root, reporter, opts) {
validate = validate.toFunction(scope)
validate.errors = null

Object.defineProperty(validate, 'error', {
get: function() {
if (!validate.errors)
return '';
return validate.errors.map(function(err) {
return err.field + ' ' + err.message;
}).join('\n');
}
})
if (Object.defineProperty) {

This comment has been minimized.

Copy link
@milne-dev

milne-dev Nov 7, 2015

what will happen if it is not defined? (it almost certainly will be)

This comment has been minimized.

Copy link
@mafintosh

mafintosh Nov 7, 2015

Author Owner

The error prop wont be set. I think most people check the .errors array instead anyway

Object.defineProperty(validate, 'error', {
get: function() {
if (!validate.errors) return ''
return validate.errors.map(function(err) {
return err.field + ' ' + err.message;
}).join('\n')
}
})
}

validate.toJSON = function() {
return schema
Expand Down

0 comments on commit 851d3cc

Please sign in to comment.