       throw new Error() unless Array.isArray(value)
       itemSchema = schema.items
       if itemSchema?
-        @executeTypeFilters(item, itemSchema) for item in value
+        @executeSchemaValidators(item, itemSchema) for item in value
       else
         value
+
+  '*':
+    minimumAndMaximumCoercion: (value, schema) ->
+      return value unless typeof value is 'number'
+      if schema.minimum? and typeof schema.minimum is 'number'
+        value = Math.max(value, schema.minimum)
+      if schema.maximum? and typeof schema.maximum is 'number'
+        value = Math.min(value, schema.maximum)
+      value

      throw new Error() if typeof value isnt 'object'
      return value unless schema.properties?
      for prop, childSchema of schema.properties
        value[prop] = @executeTypeFilters(value[prop], childSchema) if prop of value
      value

  'array':

module.exports =
class Config
  EmitterMixin.includeInto(this)
  @schemaValidators = {}

  @addSchemaValidator: (typeName, validatorFunction) ->
    @schemaValidators[typeName] ?= []
    @schemaValidators[typeName].push(validatorFunction)

  @addSchemaValidators: (filters) ->
    for typeName, functions of filters
      for name, validatorFunction of functions
        @addSchemaValidator(typeName, validatorFunction)

  @executeSchemaValidators: (value, schema) ->
    failedValidation = false
    types = schema.type
    types = [types] unless Array.isArray(types)
    for type in types
      try
        if filterFunctions = @schemaValidators[type]
          filterFunctions = filterFunctions.concat(@schemaValidators['*'])
          for filter in filterFunctions
            value = filter.call(this, value, schema)
          failedValidation = false
