           @name = def['name']
           @type = def['type']
           @label = def['label']
-          @size = def['size']
+          @size = if def['size']? then def['size']? else 1
           @help = def['help']
           @default = def['default']
+          @options = if def['options']? then def['options'] else {}
           @value = @default
-          @validators = (new Validator(v, @name) for v in def['validators'])
+          if def['validators']?
+            @validators = (new Validator(v, @name) for v in def['validators'])
+          else @validators = []
           @error = null
           @onChange = []
+          @onValidate = []
           _fields[@name] = this
 
+        _doValidate: (res, msg) ->
+          (h(res) for h in @onValidate)
+          @valid = res
+          @error = msg
+          return res    
+
         set: (value) ->
+          if value == @value then return
           @value = value
-          for h in @onChange
-            h(@value)
-
+          (h(@value) for h in @onChange)
+          this._doValidate(true)
+          
         reset: ->
           this.set(if @default then @default else null)
+          this._doValidate(true)
 
         validate: ->
           for v in @validators
             if v.validate() is false
-              @valid = false; @error = v.message; return @valid    
-          @valid = true; @error = null; return @valid
+              return this._doValidate(false, v.message)
+          this._doValidate(true)
 
+        directive: -> directives.get(@type)
 
       class Validator
         constructor: (def, fieldName) ->

## 

angular.module('CoolFormServices').
  factory('coreService', (validators)->

    return(definition) ->

      _fields = {}                  

      class Element

          @submitLabel = def['submit']
          @resetLabel = def['reset']
          @pages = (new Page(p) for p in def['pages'])
          if def['dependencies']? then switch d for d in def['dependencies']
            when 'validator' then validators.add(d)
            when 'field' then dump 'field'

        submit: -> this.validate()
        

      class Page extends Displayable
        constructor: (def) ->
