Skip to content

Commit

Permalink
refactor: use default options
Browse files Browse the repository at this point in the history
  • Loading branch information
meenahoda committed Jan 27, 2020
1 parent a021f0e commit 946e846
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/validate-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ const schema = require('../schema.json')
const validator = require('jsonschema').validate
const formatters = require('./formatters')

module.exports = function validateForm (formDefinition, options) {
module.exports = function validateForm (formDefinition, options = {}) {
const result = validator(formDefinition, schema)

// TODO: Make this more robust!
if (options === undefined) options = {}

const formatter = options.format ? formatters[options.format] : formatters.simple

if (!formatter) throw new Error(`Unknown format '${options.format}'`)
Expand Down

0 comments on commit 946e846

Please sign in to comment.