           reject new Error('Enter a valid card number')
         resolve value
 
-  expiration: (value)->
-    if !value
-      return value
+  expiration: (value) ->
+    return value unless value
 
     if @('order.type') != 'stripe'
       return value

          reject new Error('Enter a valid expiration date')
        resolve value

  cvc: (value)->
    if !value
      return value

    if @('order.type') != 'stripe'
      return value

emailRe = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/

middleware =
  isRequired: (value) ->
    return value if value && value != ''

    throw new Error 'Required'

  isEmail: (value) ->
    return value unless value

    return value.toLowerCase() if emailRe.test value

    throw new Error 'Enter a valid email'

  isNewPassword: (value) ->
    if !@get 'user.currentPassword'
      throw new Error 'Current password required' if value
      return value

    return middleware.isPassword value

  isPassword: (value) ->
    unless value
      throw new Error 'Required'

    return value if value.length >= 6
