Common Lisp Package: DATA-FORMAT-VALIDATION

Exports API for validation and conversion of user data to internal types and back again.

README:

FUNCTION

Public

DATE (OS UTIME &OPTIONAL COLON-P AT-P (PRECISION 7) (TIMEZONE *TIMEZONE*))

Formatter which formats a universal time for output as a date and time Modifiers: - os: an output stream designator - arg: a universal time - colon-p: a generalised boolean (default false). If true use month and day names in date - at-p: a generalised boolean (default false) - if true print in yyyy-mm-dd (sortable) format rather than dd-mm-yyy - precision: what precision to print it to. 6 is to the second, 7 includes timezone, a negative number counts backward. - timezone: an integer (default nil). If nil no timezone used and time is in current timezone adjusted for daylight saving time. Result: nil Examples: (format nil "~/date/" (get-universal-time)) => "19-03-2009 08:30"

ENG (OS ARG &OPTIONAL COLON-P AT-P (D 2) (PADCHAR ) (EXPONENTCHAR E))

Formatter which outputs its numerical argument `arg` in engineering format to stream `os`. It takes arguments d,padchar,exponentchar where d is the number of decimal places to display after the decimal point padchar is the character to pad the start of the number exponentchar is the character to use to display between radix and exponent It also takes the : modifier which will cause it to output the exponent as an SI units prefix rather than a number. Arguments: - `os`: an output stream designator - `arg`: a number - `colon-p`: a generalised boolean (default false) - `at-p`: a generalised boolean (default false) - ignored - `d`: an integer (default 2) - `padchar`: a character (default `space`) - `exponentchar`: a character (default `e`)) Result: nil Examples: `(format nil "~/eng/" 35000) => "35.00e+3"`

JOIN-STRINGS (STRINGS &OPTIONAL (SEPARATOR ))

Return a new string by joining together the STRINGS, separating each string with a SEPARATOR character or string

PARSE-ARGUMENTS (SPEC ARGUMENT-STRING &OPTIONAL ALLOW-SPACES)

Parse a string of whitespace delimited arguments according to spec. The specification is a list of entries each of which lists the name, and optionally type and default values. The output is an alist of variable names and parsed values. If allow-spaces is true, last element can contain spaces

PARSE-OPTIONS (SPEC OPTIONS-LIST &OPTIONAL ALLOW-OTHER-OPTIONS)

Parse an option list (alist of names and strings to be parsed) against a specification. The specification is a list of entries each of which lists the name, and optionally type and default values. The output is an alist of variable names and parsed values. Options in options-list not in spec are not returned and will signal an error unless allow-other-options is true

SPLIT-STRING (STRING &KEY COUNT (DELIMITER +WS+) REMOVE-EMPTY-SUBSEQS)

Split `string' along whitespace as defined by the sequence `ws'. Whitespace which causes a split is elided from the result. The whole string will be split, unless `max' is provided, in which case the string will be split into `max' tokens at most, the last one containing the whole rest of the given `string', if any.

Undocumented

DURATION (OS SECONDS &OPTIONAL COLON-P AT-P PRECISION WIDTH)

Private

DECODED-TIME-DAY (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-DOTW (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-HOUR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-MINUTE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-MONTH (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-SECOND (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-YEAR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DECODED-TIME-ZONE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

FORMAT-TIME (OUT UTIME &KEY (FMT RFC2822) (TIMEZONE *TIMEZONE*))

Formats a universal time for output. OUT controls where the result will go. If OUT is T, then the output is sent to the standard output stream. If it is NIL, then the output is returned in a string as the value of the call. Otherwise, OUT must be a stream to which the output will be sent. UTIME is the universal time to be output (default is current time) TZ is the time zone default will give local time. FMT is a keyword symbol specifying which output format is used as follows :RFC2822 - output as per RFC2822 for internet messages :SHORT - output in a shorter format (same as :ISO) :TIME-ONLY - outputs time as hh:mm:ss :DATE-ONLY - outputs date as dd-mm-yyyy :ISO - output as per ISO 8602

PARSE-NUMBER (STRING &KEY (START 0) (END NIL) (RADIX 10))

Given a string, and start, end, and radix parameters, produce a number according to the syntax definitions in the Common Lisp Hyperspec.

PARSE-POSITIVE-REAL-NUMBER (STRING &KEY (START 0) (END NIL) (RADIX 10))

Given a string, and start, end, and radix parameters, produce a number according to the syntax definitions in the Common Lisp Hyperspec -- except for complex numbers and negative numbers.

PARSE-REAL-NUMBER (STRING &KEY (START 0) (END NIL) (RADIX 10))

Given a string, and start, end, and radix parameters, produce a number according to the syntax definitions in the Common Lisp Hyperspec -- except for complex numbers.

PARSE-TIME (TIME-STRING &KEY (START 0) (END (LENGTH TIME-STRING)) (ERROR-ON-MISMATCH NIL) (PATTERNS *DEFAULT-DATE-TIME-PATTERNS*) (DEFAULT-SECONDS NIL) (DEFAULT-MINUTES NIL) (DEFAULT-HOURS NIL) (DEFAULT-DAY NIL) (DEFAULT-MONTH NIL) (DEFAULT-YEAR NIL) (DEFAULT-ZONE NIL) (DEFAULT-WEEKDAY NIL))

Tries very hard to make sense out of the argument time-string and returns a single integer representing the universal time if successful. If not, it returns nil. If the :error-on-mismatch keyword is true, parse-time will signal an error instead of returning nil. Default values for each part of the time/date can be specified by the appropriate :default- keyword. These keywords can be given a numeric value or the keyword :current to set them to the current value. The default-default values are 00:00:00 on the current date, current time-zone.

Undocumented

AM-PM (STRING)

CONVERT-TO-UNITIME (PARSED-VALUES)

COPY-DECODED-TIME (INSTANCE)

DATE-DIVIDER (CHARACTER)

DAY (NUMBER)

DEAL-WITH-AM-PM (FORM-VALUE PARSED-VALUES)

DEAL-WITH-IZONE (FORM-VALUE PARSED-VALUES)

DEAL-WITH-NOON-MIDN (FORM-VALUE PARSED-VALUES)

SETFDECODED-TIME-DAY (NEW-VALUE INSTANCE)

SETFDECODED-TIME-DOTW (NEW-VALUE INSTANCE)

SETFDECODED-TIME-HOUR (NEW-VALUE INSTANCE)

SETFDECODED-TIME-MINUTE (NEW-VALUE INSTANCE)

SETFDECODED-TIME-MONTH (NEW-VALUE INSTANCE)

DECODED-TIME-P (OBJECT)

SETFDECODED-TIME-SECOND (NEW-VALUE INSTANCE)

SETFDECODED-TIME-YEAR (NEW-VALUE INSTANCE)

SETFDECODED-TIME-ZONE (NEW-VALUE INSTANCE)

DECOMPOSE-STRING (STRING &KEY (START 0) (END (LENGTH STRING)) (RADIX 10))

HOUR (NUMBER)

IS-NIL-STRING (STRING)

IZONE (THING)

LOOKUP-FIELD (NAME FIELD-SPECIFICATIONS)

MAKE-DECODED-TIME (&KEY ((SECOND DUM31) 0) ((MINUTE DUM32) 0) ((HOUR DUM33) 0) ((DAY DUM34) 1) ((MONTH DUM35) 1) ((YEAR DUM36) 1900) ((ZONE DUM37) NIL) ((DOTW DUM38) 0))

MAKE-DEFAULT-TIME (DEF-SEC DEF-MIN DEF-HOUR DEF-DAY DEF-MON DEF-YEAR DEF-ZONE DEF-DOTW)

MATCH-PATTERN (PATTERN DATUM DATUM-LENGTH)

MATCH-PATTERN-ELEMENT (PATTERN-ELEMENT DATUM-ELEMENT)

MATCH-SUBSTRING (SUBSTRING)

MINUTE (NUMBER)

MONTH (THING)

NOON-MIDN (STRING)

NOW (PARSED-VALUES)

NUMBER-VALUE (X)

PARSE-INTEGER-AND-PLACES (STRING START END &KEY (RADIX 10))

PARSE-INTEGERS (STRING START END SPLITTING-POINTS &KEY (RADIX 10))

PLACES (X)

SECONDP (NUMBER)

SET-CURRENT-VALUE (VALUES-STRUCTURE &KEY (TIME NIL) (DATE NIL) (ZONE NIL))

SET-TIME-VALUES (STRING-FORM PARSED-VALUES)

SPECIAL-STRING-P (STRING)

TIME-DIVIDER (CHARACTER)

TODAY (PARSED-VALUES)

TOMORROW (PARSED-VALUES)

WEEKDAY (STRING)

WHITE-SPACE-P (X)

YEAR (NUMBER)

YESTERDAY (PARSED-VALUES)

ZONE (THING)

MACRO

Private

INVALID-FORMAT-ERROR (TYPE VALUE &REST REASON)

Generate an invalid-format error for given value using reason

Undocumented

HASHLIST (LIST TABLE)

GENERIC-FUNCTION

Public

EQUIVALENT (SPECIFICATION INPUT REFERENCE &KEY (TOL 0.001) (TEST #'EQUAL) &ALLOW-OTHER-KEYS)

Returns true if the parsed value input is equivalent (equals) the reference value according to the stype specification. If specification is a list the first element specifies the actual validation method and the rest of the list are passed as keyword arguments to the specific method.

FORMAT-OUTPUT (SPECIFICATION VALUE &KEY FMT FORMAT RADIX (PACKAGE *PACKAGE*) (MULTIPLEP NIL) (PRESERVE-NEWLINES-P T) STREAM IF-NO-SPECIFICATION FIELD-SPECIFICATIONS NIL-ALLOWED (MULT 1) (%-P T) (PLACES 0) (UNITS T) (PADCHAR ) (DECIMAL-PLACES 2) (ZONE *TIMEZONE*) (IF-NIL NIL) (SEPARATOR , ) TYPE &ALLOW-OTHER-KEYS)

Return a string representation of value formatted according to a specification. If specification is a list the first element specifies the actual validation method and the rest of the list are passed as keyword arguments to the specific method e.g. (format-output '(date :fmt :rfc2822) (get-universal-time)) >"Mon, 10 Jul 2006 15:43:45 +00"

PARSE-INPUT (SPECIFICATION INPUT &KEY (RATIONAL-AS-FLOAT-P NIL) FORMAT (CONVERT #'IDENTITY) (PACKAGE KEYWORD) WILD-ALLOWED MUST-EXIST (REPLACEMENT -) (IF-INVALID ERROR) (PATTERNS *DEFAULT-DATE-TIME-PATTERNS*) (ZONE NIL) (UNITS T) (SKIP-BLANKS-P T) FIELD-SPECIFICATIONS (PRESERVE-NEWLINES-P T) (TERMINATION-TEST #'(LAMBDA (LINE) (ZEROP (LENGTH LINE)))) IF-NO-SPECIFICATION (MULTIPLEP NIL) (SEPARATOR , ) TYPE SET (TEST #'EQUAL) KEY (STRIP-RETURN NIL) MIN-WORD-COUNT MAX-WORD-COUNT (MIN-LENGTH 0) MAX-LENGTH MIN MAX NIL-ALLOWED (RADIX 10) &ALLOW-OTHER-KEYS)

Validate and parse user input according to specification, returning the validated object. Throws an invalid-format condition if input is invalid. If specification is a list the first element specifies the actual validation method and the rest of the list are passed as keyword arguments to the specific method e.g. (parse-input '(integer :min 0) input) will return the integer value from strin if it is >0, or signal and invalid-format condition if not. (parse-input '(member :type integer :set (1 5 7)) input) will return it only if it has a value in the set. The use-value restart may be used to provide substitute value if the input is invalid.

Undocumented

INVALID-FORMAT-REASON (CONDITION)

INVALID-FORMAT-TYPE (CONDITION)

INVALID-FORMAT-VALUE (CONDITION)

Private

Undocumented

REASON (CONDITION)

VALUE (CONDITION)

VARIABLE

Public

*TIMEZONE*

Default timezone for date handling

Private

*ERROR-ON-MISMATCH*

If t, an error will be signalled if parse-time is unable to determine the time/date format of the string.

+MONTH-NAMES+

The names of the months.

+TIME-ZONES+

The string representations of the time zones.

+WEEK-DAYS+

The names of the days of the week.

+WS+

Bag of white space delimiter characters

Undocumented

*DEFAULT-DATE-TIME-PATTERNS*

*HTTP-DATE-TIME-PATTERNS*

*MONTH-STRINGS*

*SPECIAL-STRINGS*

*WEEKDAY-STRINGS*

*WHITE-SPACE-CHARACTERS*

*ZONE-STRINGS*

+ENGINEERING-UNITS+

+ROMAN-NUMERAL-MAP+

DATE-DIVIDERS

MONTH-TABLE-SIZE

SPECIAL-TABLE-SIZE

TIME-DIVIDERS

WEEKDAY-TABLE-SIZE

WHITESPACE-CHARS

ZONE-TABLE-SIZE

CLASS

Private

Undocumented

DECODED-TIME

CONDITION

Public

Undocumented

INVALID-FORMAT

Private

Undocumented

INVALID-NUMBER