GithubHelp home page GithubHelp logo

shinmera / ratify Goto Github PK

View Code? Open in Web Editor NEW
29.0 5.0 7.0 79 KB

A collection of Common Lisp utilities to ratify, validate and parse inputs.

Home Page: https://shinmera.github.io/ratify

License: zlib License

Common Lisp 20.75% HTML 79.25%

ratify's Introduction

About Ratify

Ratify is a collection of utilities to perform validation checks and parsing. The main intention of usage for this is in web-applications in order to check form inputs for correctness and automatically parse them into their proper representations or return meaningful errors.

How To

Ratify has a load of TEST-* functions, each accompanied by a predicate equivalent. The TEST-* functions will signal errors of type RATIFICATION-ERROR if the test fails, whereas the predicates will simply return NIL. Both will return the passed argument unmodified on success. Some of the tests have an equivalent PARSE-* function in order to turn the string into a more useful representation.

The main interaction with Ratify is not supposed to be directly with the TEST-* and PARSE-* functions however, but rather through the TEST and PARSE wrapper functions. Both also have a macro shorthand to perform many tests and parsings at once, PERFORM-COMBINED-TESTS and WITH-PARSED-FORMS. These macros will perform as many tests as possible and only signal an error right after all tests have been made. This error is of type COMBINED-ERROR, which contains all the errors that occurred during the testing.

(ratify:perform-combined-tests
  (:integer "45")
  (:date "2014-08-01")
  (:ratio "566/21"))

(ratify:perform-combined-tests
  (:integer "4.5" "e")
  (:date "2014-08-01" "2014" "2014-55-99")
  (:ratio "566/21" "5.6/21"))
; Evaluation aborted on #<RATIFY-TESTING:COMBINED-ERROR {10074E51D3}>.

Or to perform parsing:

(let ((int "45")
      (url "http://foo.bar/baz.jp?what=ever#hashtag")
      (uri "things-are://sometimes:[email protected]/damn?protocols=i'm#telling+you!")
      (dt "2014-08-01T21:23:01"))
  (ratify:with-parsed-forms ((:integer int) (:url url) (:uri uri) (:datetime dt))
    (list int url uri dt)))

If an error occurs, the ERRORS function gives access to the list of errors that the COMBINED-ERROR contains. For a complete list of testing and parsing functions, please see the symbol index. The syntax grammar used to describe the valid values in the docstrings of each test is regex with the addition of <brackets> to refer to other tests, sometimes accompanied with a second line that describes limits of the values.

ratify's People

Contributors

bnmcgn avatar cactot avatar shinmera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ratify's Issues

Error: Attempt to take the value of the unbound variable `ratify-testing::NIL' during Quicklisp install

Error: Attempt to take the value of the unbound variable `ratify-testing::NIL'.
[condition type: unbound-variable]
With Allegro 10.1SMP ;
Stopped during std quicklisp install
=====here's the log:
cg-user(74): (ql:quickload "ratify")
To load "ratify":
Load 4 ASDF systems:
alexandria asdf cl-ppcre local-time
Install 2 Quicklisp releases:
parse-float ratify
; Fetching #<url "http://beta.quicklisp.org/archive/parse-float/2017-10-19/parse-float-20171019-git.tgz">
; 4.59KB

4,696 bytes in 0.01 seconds (655.13KB/sec)
; Fetching #<url "http://beta.quicklisp.org/archive/ratify/2018-01-31/ratify-20180131-git.tgz">
; 31.35KB

32,107 bytes in 0.07 seconds (461.10KB/sec)
; Loading "ratify"
[package cl-ppcre]................................
..................................................
[package bordeaux-threads]........................
[package cl-fad]..................................
[package path]....................................
[package local-time]..............................
[package parse-float].............................
[package ratify-toolkit]..........................
[package ratify-testing]..........................
[package ratify-parsing]..........................
[package ratify-uri]..............................
[package ratify-url]..............................
[package ratify-email]............................
[package ratify-css]..............................
[package ratify-date].............................
[package ratify-types]............................
[package ratify-html].............................
[package ratify]...
Error: Attempt to take the value of the unbound variable `ratify-testing::NIL'.
[condition type: unbound-variable]
=====here's the backtrace:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.