The sanitized-params Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The sanitized-params Reference Manual

This is the sanitized-params Reference Manual, version 0.1, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:33:02 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Sanitized-Params

Build Status Coverage Status Quicklisp dist

Sanitized-Params is for checking required keys and filtering invalid key-values in an association list.

Usage

(use-package :sanitized-params)

;; Check every elements satisfies #'integerp
(sanitize
 (list-of #'integerp)
 '(1 2 3))
;=> (1 2 3)

;; Return only satisfied values
(sanitize
 (list-of #'integerp)
 '(1 2 "a" 3))
;=> (1 2 3)

;; Check the association list has a key "name"
(sanitize
 (alist (requires "name"))
 '(("name" . "Eitaro Fukamachi")))
;=> '(("name" . "Eitaro Fukamachi"))

(sanitize
 (alist (requires "name"))
 '(("name" . "Eitaro Fukamachi")
   ("address" . "Japan")))
;=> (("name" . "Eitaro Fukamachi") ("address" . "Japan"))

;; Whitelist keys
(sanitize
 (alist (permits "name" "email"))
 '(("name" . "Eitaro Fukamachi")))
;=> (("name" . "Eitaro Fukamachi"))

(sanitize
 (alist (permits "name" "email"))
 '(("name" . "Eitaro Fukamachi") ("address" . "Japan")))
;-> ERROR: Unpermitted keys: "address

;; Permits only initargs of a class
(defclass person () ((name :initarg :name) (email :initarg :email)))

(sanitize
 (alist (permits (initargs-of 'person)))
 '(("name" . "Eitaro Fukamachi")))
;=> (("name" . "Eitaro Fukamachi"))

;; Nested rule
(sanitize
 (alist
  (requires "name")
  (satisfies "email" #'listp)
  (satisfies "friends"
             (list-of
              (alist
               (requires "name")
               (satisfies "family" (list-of
                                    (alist (permits "name"))))
               (satisfies "hobbies" #'listp)))))
 '(("name" . "Eitaro Fukamachi")
   ("email" . ("e.arrows@gmail.com" "another@gmail.com"))
   ("friends" . ((("name" . "Masatoshi Sano")
                  ("family" . ())
                  ("hobbies" . ("rocket" "lisp")))))))
;=> (("name" . "Eitaro Fukamachi")
;    ("email" "e.arrows@gmail.com" "another@gmail.com")
;    ("friends"
;     (("name" . "Masatoshi Sano") ("family") ("hobbies" "rocket" "lisp"))))

Author

Copyright

Copyright (c) 2016 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 2-Clause License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 sanitized-params

Author

Eitaro Fukamachi

License

BSD 2-Clause

Description

Sanitizer for parameters

Long Description

# Sanitized-Params

[![Build Status](https://travis-ci.org/fukamachi/sanitized-params.svg?branch=master)](https://travis-ci.org/fukamachi/sanitized-params) [![Coverage Status](https://coveralls.io/repos/fukamachi/sanitized-params/badge.svg?branch=master)](https://coveralls.io/r/fukamachi/sanitized-params) [![Quicklisp dist](http://quickdocs.org/badge/sanitized-params.svg)](http://quickdocs.org/sanitized-params/)

Sanitized-Params is for checking required keys and filtering invalid key-values in an association list.

## Usage

“‘common-lisp
(use-package :sanitized-params)

;; Check every elements satisfies #’integerp
(sanitize
(list-of #’integerp)
’(1 2 3))
;=> (1 2 3)

;; Return only satisfied values
(sanitize
(list-of #’integerp)
’(1 2 "a" 3))
;=> (1 2 3)

;; Check the association list has a key "name"
(sanitize
(alist (requires "name"))
’(("name" . "Eitaro Fukamachi")))
;=> ’(("name" . "Eitaro Fukamachi"))

(sanitize
(alist (requires "name"))
’(("name" . "Eitaro Fukamachi")
("address" . "Japan")))
;=> (("name" . "Eitaro Fukamachi") ("address" . "Japan"))

;; Whitelist keys
(sanitize
(alist (permits "name" "email"))
’(("name" . "Eitaro Fukamachi")))
;=> (("name" . "Eitaro Fukamachi"))

(sanitize
(alist (permits "name" "email"))
’(("name" . "Eitaro Fukamachi") ("address" . "Japan")))
;-> ERROR: Unpermitted keys: "address

;; Permits only initargs of a class
(defclass person () ((name :initarg :name) (email :initarg :email)))

(sanitize
(alist (permits (initargs-of ’person)))
’(("name" . "Eitaro Fukamachi")))
;=> (("name" . "Eitaro Fukamachi"))

;; Nested rule
(sanitize
(alist
(requires "name")
(satisfies "email" #’listp)
(satisfies "friends"
(list-of
(alist
(requires "name")
(satisfies "family" (list-of
(alist (permits "name"))))
(satisfies "hobbies" #’listp)))))
’(("name" . "Eitaro Fukamachi")
("email" . ("e.arrows@gmail.com" "another@gmail.com"))
("friends" . ((("name" . "Masatoshi Sano")
("family" . ())
("hobbies" . ("rocket" "lisp")))))))
;=> (("name" . "Eitaro Fukamachi")
; ("email" "e.arrows@gmail.com" "another@gmail.com")
; ("friends"
; (("name" . "Masatoshi Sano") ("family") ("hobbies" "rocket" "lisp"))))
“‘

## Author

* Eitaro Fukamachi (e.arrows@gmail.com)

## Copyright

Copyright (c) 2016 Eitaro Fukamachi (e.arrows@gmail.com)

## License

Licensed under the BSD 2-Clause License.

Version

0.1

Dependencies
Source

sanitized-params.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 sanitized-params/src

Parent

sanitized-params (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 sanitized-params.asd

Location

sanitized-params.asd

Systems

sanitized-params (system)

Packages

sanitized-params-asd


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 sanitized-params/src/sanitized-params.lisp

Dependency

error.lisp (file)

Parent

src (module)

Location

src/sanitized-params.lisp

Packages

sanitized-params

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

4.1.3 sanitized-params/src/error.lisp

Parent

src (module)

Location

src/error.lisp

Packages

sanitized-params.error

Exported Definitions
Internal Definitions

condition-continue (function)


Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 sanitized-params-asd

Source

sanitized-params.asd

Use List

Next: , Previous: , Up: Packages   [Contents][Index]

5.2 sanitized-params

Source

sanitized-params.lisp (file)

Use List
Exported Definitions
Internal Definitions

Previous: , Up: Packages   [Contents][Index]

5.3 sanitized-params.error

Source

error.lisp (file)

Use List

common-lisp

Used By List

sanitized-params

Exported Definitions
Internal Definitions

condition-continue (function)


Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Macros

Macro: alist &rest PREDS
Package

sanitized-params

Source

sanitized-params.lisp (file)

Macro: with-validation &body BODY
Package

sanitized-params.error

Source

error.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Functions

Function: initargs-of CLASS
Package

sanitized-params

Source

sanitized-params.lisp (file)

Function: list-of PRED
Package

sanitized-params

Source

sanitized-params.lisp (file)

Function: sanitize PATTERN PARAMS
Package

sanitized-params

Source

sanitized-params.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Generic functions

Generic Function: invalid-keys CONDITION
Generic Function: (setf invalid-keys) NEW-VALUE CONDITION
Package

sanitized-params.error

Methods
Method: invalid-keys (CONDITION validation-error)
Method: (setf invalid-keys) NEW-VALUE (CONDITION validation-error)
Source

error.lisp (file)

Generic Function: missing-keys CONDITION
Generic Function: (setf missing-keys) NEW-VALUE CONDITION
Package

sanitized-params.error

Methods
Method: missing-keys (CONDITION validation-error)
Method: (setf missing-keys) NEW-VALUE (CONDITION validation-error)
Source

error.lisp (file)

Generic Function: unpermitted-keys CONDITION
Generic Function: (setf unpermitted-keys) NEW-VALUE CONDITION
Package

sanitized-params.error

Methods
Method: unpermitted-keys (CONDITION validation-error)
Method: (setf unpermitted-keys) NEW-VALUE (CONDITION validation-error)
Source

error.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.4 Conditions

Condition: missing-required-keys ()
Package

sanitized-params.error

Source

error.lisp (file)

Direct superclasses

condition (condition)

Direct slots
Slot: keys
Initargs

:keys

Condition: not-satisfied-key ()
Package

sanitized-params.error

Source

error.lisp (file)

Direct superclasses

condition (condition)

Direct slots
Slot: key
Initargs

:key

Slot: pred
Initargs

:pred

Condition: unpermitted-keys ()
Package

sanitized-params.error

Source

error.lisp (file)

Direct superclasses

condition (condition)

Direct slots
Slot: keys
Initargs

:keys

Condition: validation-error ()
Package

sanitized-params.error

Source

error.lisp (file)

Direct superclasses

error (condition)

Direct methods
Direct slots
Slot: missing
Initargs

:missing

Initform

(quote (quote nil))

Readers

missing-keys (generic function)

Writers

(setf missing-keys) (generic function)

Slot: invalid
Initargs

:invalid

Initform

(quote (quote nil))

Readers

invalid-keys (generic function)

Writers

(setf invalid-keys) (generic function)

Slot: unpermitted
Initargs

:unpermitted

Initform

(quote (quote nil))

Readers

unpermitted-keys (generic function)

Writers

(setf unpermitted-keys) (generic function)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Special variables

Special Variable: *raise-unpermitted-keys*
Package

sanitized-params

Source

sanitized-params.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: aget PARAMS KEY
Package

sanitized-params

Source

sanitized-params.lisp (file)

Function: condition-continue CONDITION
Package

sanitized-params.error

Source

error.lisp (file)

Function: remove-from-alist ALIST KEY
Package

sanitized-params

Source

sanitized-params.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M   S  
Index Entry  Section

F
File, Lisp, sanitized-params.asd: The sanitized-params<dot>asd file
File, Lisp, sanitized-params/src/error.lisp: The sanitized-params/src/error<dot>lisp file
File, Lisp, sanitized-params/src/sanitized-params.lisp: The sanitized-params/src/sanitized-params<dot>lisp file

L
Lisp File, sanitized-params.asd: The sanitized-params<dot>asd file
Lisp File, sanitized-params/src/error.lisp: The sanitized-params/src/error<dot>lisp file
Lisp File, sanitized-params/src/sanitized-params.lisp: The sanitized-params/src/sanitized-params<dot>lisp file

M
Module, sanitized-params/src: The sanitized-params/src module

S
sanitized-params.asd: The sanitized-params<dot>asd file
sanitized-params/src: The sanitized-params/src module
sanitized-params/src/error.lisp: The sanitized-params/src/error<dot>lisp file
sanitized-params/src/sanitized-params.lisp: The sanitized-params/src/sanitized-params<dot>lisp file

Jump to:   F   L   M   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
A   C   F   G   I   L   M   R   S   U   W  
Index Entry  Section

(
(setf invalid-keys): Exported generic functions
(setf invalid-keys): Exported generic functions
(setf missing-keys): Exported generic functions
(setf missing-keys): Exported generic functions
(setf unpermitted-keys): Exported generic functions
(setf unpermitted-keys): Exported generic functions

A
aget: Internal functions
alist: Exported macros

C
condition-continue: Internal functions

F
Function, aget: Internal functions
Function, condition-continue: Internal functions
Function, initargs-of: Exported functions
Function, list-of: Exported functions
Function, remove-from-alist: Internal functions
Function, sanitize: Exported functions

G
Generic Function, (setf invalid-keys): Exported generic functions
Generic Function, (setf missing-keys): Exported generic functions
Generic Function, (setf unpermitted-keys): Exported generic functions
Generic Function, invalid-keys: Exported generic functions
Generic Function, missing-keys: Exported generic functions
Generic Function, unpermitted-keys: Exported generic functions

I
initargs-of: Exported functions
invalid-keys: Exported generic functions
invalid-keys: Exported generic functions

L
list-of: Exported functions

M
Macro, alist: Exported macros
Macro, with-validation: Exported macros
Method, (setf invalid-keys): Exported generic functions
Method, (setf missing-keys): Exported generic functions
Method, (setf unpermitted-keys): Exported generic functions
Method, invalid-keys: Exported generic functions
Method, missing-keys: Exported generic functions
Method, unpermitted-keys: Exported generic functions
missing-keys: Exported generic functions
missing-keys: Exported generic functions

R
remove-from-alist: Internal functions

S
sanitize: Exported functions

U
unpermitted-keys: Exported generic functions
unpermitted-keys: Exported generic functions

W
with-validation: Exported macros

Jump to:   (  
A   C   F   G   I   L   M   R   S   U   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
I   K   M   P   S   U  
Index Entry  Section

*
*raise-unpermitted-keys*: Internal special variables

I
invalid: Exported conditions

K
key: Exported conditions
keys: Exported conditions
keys: Exported conditions

M
missing: Exported conditions

P
pred: Exported conditions

S
Slot, invalid: Exported conditions
Slot, key: Exported conditions
Slot, keys: Exported conditions
Slot, keys: Exported conditions
Slot, missing: Exported conditions
Slot, pred: Exported conditions
Slot, unpermitted: Exported conditions
Special Variable, *raise-unpermitted-keys*: Internal special variables

U
unpermitted: Exported conditions

Jump to:   *  
I   K   M   P   S   U  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   M   N   P   S   U   V  
Index Entry  Section

C
Condition, missing-required-keys: Exported conditions
Condition, not-satisfied-key: Exported conditions
Condition, unpermitted-keys: Exported conditions
Condition, validation-error: Exported conditions

M
missing-required-keys: Exported conditions

N
not-satisfied-key: Exported conditions

P
Package, sanitized-params: The sanitized-params package
Package, sanitized-params-asd: The sanitized-params-asd package
Package, sanitized-params.error: The sanitized-params<dot>error package

S
sanitized-params: The sanitized-params system
sanitized-params: The sanitized-params package
sanitized-params-asd: The sanitized-params-asd package
sanitized-params.error: The sanitized-params<dot>error package
System, sanitized-params: The sanitized-params system

U
unpermitted-keys: Exported conditions

V
validation-error: Exported conditions

Jump to:   C   M   N   P   S   U   V