Hi Guix!
Does define-record-type* support creating a validator/sanitzer that
validates the entire record during creation? I know you can create
sanitzers for individual fields (example below from the docstring).
--8<---------------cut here---------------start------------->8---
A field can also have an associated \"sanitizer\", which is a procedure that
takes a user-supplied field value and returns a \"sanitized\" value for the
field:
(define-record-type* <thing> thing make-thing
thing?
this-thing
(name thing-name
(sanitize (lambda (value)
(cond ((string? value) value)
((symbol? value) (symbol->string value))
(else (throw 'bad! value)))))))
--8<---------------cut here---------------end--------------->8---
I think it would be valuable to validate fields in relation to each
other. For example, verifying that mutually exclusive fields aren't all
set to #t.
However before I actually open this as a bug or post about it on
guix-devel I want to check if such a thing already exists. Or if there's
an equivalent method to achieve a similar result that's already used in
the code.
I imagine in general we don't want too many records that can have
mutually exclusive fields. However, (I believe) that already exists in
the current code base. For example, the file-system record has both
needed-for-boot? and dependencies, but if mount-at-boot? is set
dependencies is ignored.
--
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.