Parameterize over error message in make-simple-default-setter
This commit is contained in:
parent
15f07f8d4a
commit
2268fe3231
|
@ -39,13 +39,13 @@
|
||||||
,(field-attributes-default attributes)
|
,(field-attributes-default attributes)
|
||||||
,(field-attributes-others attributes))))))
|
,(field-attributes-others attributes))))))
|
||||||
|
|
||||||
(define (make-simple-default-setter default-pred?)
|
(define (make-simple-default-setter default-pred? error-msg-types)
|
||||||
(lambda (input-field value)
|
(lambda (input-field value)
|
||||||
(if (default-pred? value)
|
(if (default-pred? value)
|
||||||
(set-field-attributes-default!
|
(set-field-attributes-default!
|
||||||
(input-field-attributes input-field)
|
(input-field-attributes input-field)
|
||||||
`(value ,value))
|
`(value ,value))
|
||||||
(error "Default value must be a number or a string or a symbol."
|
(error (format #f "Default value must be ~a." error-msg-types)
|
||||||
value))
|
value))
|
||||||
(touch-input-field! input-field)))
|
(touch-input-field! input-field)))
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
(define simple-default? string-or-symbol?)
|
(define simple-default? string-or-symbol?)
|
||||||
|
|
||||||
(define set-simple-field-default!
|
(define set-simple-field-default!
|
||||||
(make-simple-default-setter simple-default?))
|
(make-simple-default-setter simple-default? "a string or a symbol"))
|
||||||
|
|
||||||
(define (second-arg first second) second)
|
(define (second-arg first second) second)
|
||||||
|
|
||||||
|
@ -76,7 +76,8 @@
|
||||||
(simple-field-maker "text" "number"
|
(simple-field-maker "text" "number"
|
||||||
number-field-default? number-field-transformer))
|
number-field-default? number-field-transformer))
|
||||||
(define set-number-field-value!
|
(define set-number-field-value!
|
||||||
(make-simple-default-setter number-field-default?))
|
(make-simple-default-setter number-field-default?
|
||||||
|
"a number a string or a symbol"))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; hidden input-field
|
;;; hidden input-field
|
||||||
|
|
Loading…
Reference in New Issue