From 73ed85d736b7d57d19cff5b70b1c2181700b1e7b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 19 Apr 2016 18:39:21 +0200 Subject: [PATCH 1/9] Generate documentation --- latest/api/css/default.css | 442 +++++++++++++++++++++ latest/api/index.html | 2 + latest/api/promesa.core.html | 2 + latest/api/promesa.monad.html | 2 + latest/api/promesa.protocols.html | 2 + latest/api/struct.core.html | 2 + latest/index.html | 623 ++++++++++++++++++++++++++++++ 7 files changed, 1075 insertions(+) create mode 100644 latest/api/css/default.css create mode 100644 latest/api/index.html create mode 100644 latest/api/promesa.core.html create mode 100644 latest/api/promesa.monad.html create mode 100644 latest/api/promesa.protocols.html create mode 100644 latest/api/struct.core.html create mode 100644 latest/index.html diff --git a/latest/api/css/default.css b/latest/api/css/default.css new file mode 100644 index 0000000..257ab2c --- /dev/null +++ b/latest/api/css/default.css @@ -0,0 +1,442 @@ +@import url(http://fonts.googleapis.com/css?family=Droid+Sans+Mono:200,300,400); +@import url(http://fonts.googleapis.com/css?family=Lato:light,regular); +@import url(http://fonts.googleapis.com/css?family=Ubuntu:300,400,500); + +body { + font-family: "Lato", Helvetica, Arial, sans-serif; + font-weight: 300; + color:#585858; + font-size: 100%; + margin: 0px; +} + +pre, code { + font-family: "Droid Sans Mono","DejaVu Sans Mono","Monospace",monospace; + font-weight: 300; +} + +section.container { + display: flex; + font-size: 100%; +} + +h2 { + font-weight: normal; + font-size: 3em; + padding: 10px 0 2px 0; + margin: 0; +} + +header { + color: #333; + padding: 10px; +} + +header small { + font-style: italic; +} + +header h1 { + margin: 0; + padding: 0; + /* font-size: 12pt; */ + font-weight: lighter; + /* text-shadow: -1px -1px 0px #333; */ +} + +header h1 a { + color: #333; + /* font-size: 32px; */ + font-weight: 400; + text-decoration: none; +} + +#content { + overflow: auto; + background: #fff; + color: #333; + padding: 0 18px; + font-size: 1.3em; +} + +#namespaces { + border-right: solid 1px #cccccc; + min-width: 200px; + padding-right: 15px; +} + +#vars { + border-right: solid 1px #cccccc; + width: 200px; +} + +.sidebar { + overflow: auto; +} + +.sidebar a { + color: #333; + display: block; + text-decoration: none; +} + +.sidebar h3 { + margin: 0; + padding: 10px 10px 0 10px; + font-size: 19px; + font-weight: normal; +} + +.sidebar ul { + padding: 0.5em 0em; + margin: 0; +} + +.sidebar li { + display: block; + vertical-align: middle; +} + +.sidebar li a, .sidebar li .no-link { + border-left: 3px solid transparent; + padding: 0 15px; + white-space: nowrap; +} + +.sidebar li .no-link { + display: block; + color: #777; + font-style: italic; +} + +.sidebar li .inner { + display: inline-block; + padding-top: 7px; + height: 24px; +} + +.sidebar li a, .sidebar li .tree { + height: 31px; + /* height: 25px; */ +} + +.depth-1 .inner { padding-left: 2px; } +.depth-2 .inner { padding-left: 6px; } +.depth-3 .inner { padding-left: 20px; } +.depth-4 .inner { padding-left: 34px; } +.depth-5 .inner { padding-left: 48px; } +.depth-6 .inner { padding-left: 62px; } + +.sidebar li .tree { + display: block; + float: left; + position: relative; + top: -10px; + margin: 0 4px 0 0; + padding: 0; +} + +.sidebar li.depth-1 .tree { + display: none; +} + +.sidebar li .tree .top, .sidebar li .tree .bottom { + display: block; + margin: 0; + padding: 0; + width: 7px; +} + +.sidebar li .tree .top { + border-left: 1px solid #aaa; + border-bottom: 1px solid #aaa; + height: 19px; +} + +.sidebar li .tree .bottom { + height: 22px; +} + +.sidebar li.branch .tree .bottom { + border-left: 1px solid #aaa; +} + +#namespaces li.current a { + border-left: 3px solid #a33; + border-left: 3px solid #7a2518; + color: #a33; + color: #7a2518; + +} + +#vars li.current a { + border-left: 3px solid #33a; + color: #33a; +} + +.namespace-docs h2 { + color: #7a2518; +} + +.namespace-docs h3 a { + color: #ba3925; + font-family: "Droid Sans Mono","DejaVu Sans Mono","Monospace",monospace; + font-weight: 400; + text-decoration: none; +} + +.namespace-docs .usage code { + display: block; + color: #777; + margin: 2px 0; + font-size: 0.6em; +} + +/* .usage code:first-child { */ +/* padding-top: 10px; */ +/* } */ + + + +.namespace-index h3 a { + text-decoration: none; + color: #ba3925; + font-family: "Droid Sans Mono","DejaVu Sans Mono","Monospace",monospace; + font-weight: 300; +} + +.public h3 { + margin: 0; +} + +.public { + margin: 0; + border-top: 1px solid #efefef; + padding-top: 14px; + padding-bottom: 6px; +} + +.public:last-child { + margin-bottom: 20%; +} + +.members .public:last-child { + margin-bottom: 0; +} + +.members { + margin: 15px 0; +} + +.members h4 { + color: #555; + font-weight: normal; + font-variant: small-caps; + margin: 0 0 5px 0; +} + +.members .inner { + padding-top: 5px; + padding-left: 12px; + margin-top: 2px; + margin-left: 7px; + border-left: 1px solid #bbb; +} + +#content .members .inner h3 { + /* font-size: 12pt; */ +} + +.members .public { + border-top: none; + margin-top: 0; + padding-top: 6px; + padding-bottom: 0; +} + +.members .public:first-child { + padding-top: 0; +} + +h4.type, +h4.dynamic, +h4.added, +h4.deprecated { + margin: 3px 10px 10spx 0; + font-weight: bold; + font-variant: small-caps; +} + +.public h4.type, +.public h4.dynamic, +.public h4.added, +.public h4.deprecated { + font-weight: bold; + /* margin: 3px 0 0 10px; */ + font-size: 0.7em; +} + +.members h4.type, +.members h4.added, +.members h4.deprecated { + margin-top: 1px; +} + +h4.type { + color: #717171; +} + +h4.dynamic { + color: #9933aa; +} + +h4.added { + color: #508820; +} + +h4.deprecated { + color: #880000; +} + +.namespace { + margin-bottom: 40px; +} + +.namespace:last-child { + margin-bottom: 10%; +} + +.index { + padding: 0; + margin: 15px 0; +} + +.index * { + display: inline; +} + +.index p { + padding-right: 3px; +} + +.index li { + padding-right: 5px; +} + +.index li a { + color: #333; + font-family: "Droid Sans Mono","DejaVu Sans Mono","Monospace",monospace; + font-size: 0.8em; + text-decoration: none; + font-weight: 300; +} + +.index ul { + padding-left: 0; +} + +p { + margin: 15px 0; +} + +.public p:first-child, .public pre.plaintext { + margin-top: 12px; +} + +.doc { + margin: 0 0 26px 0; + clear: both; +} + +.public .doc { + margin: 0; +} + +.namespace-index .doc { + margin-bottom: 20px; +} + +.namespace-index .namespace .doc { + margin-bottom: 10px; +} + +.markdown { + /* line-height: 18px; */ + /* font-size: 16px; */ +} + +.doc, .public, .namespace .index { + max-width: 780px; + overflow-x: visible; +} + +.markdown code, .src-link a { + border-radius: 2px; + font-size: 0.8em; + color: #444; +} + +.markdown pre { + background: #f4f4f4; + border: 1px solid #e0e0e0; + /* border-radius: 2px; */ + padding: 5px 5px; + border-top: 1px solid #e0e0e0; + border-bottom: 1px solid #e0e0e0; +} + +.markdown pre code { + background: transparent; + border: none; +} + +.doc ul, .doc ol { + padding-left: 30px; +} + +.doc table { + border-collapse: collapse; + margin: 0 10px; +} + +.doc table td, .doc table th { + border: 1px solid #dddddd; + padding: 4px 6px; +} + +.doc table th { + background: #f2f2f2; +} + +.doc dl { + margin: 0 10px 20px 10px; +} + +.doc dl dt { + font-weight: bold; + margin: 0; + padding: 3px 0; + border-bottom: 1px solid #ddd; +} + +.doc dl dd { + padding: 5px 0; + margin: 0 0 5px 10px; +} + +.doc abbr { + border-bottom: 1px dotted #333; + font-variant: none + cursor: help; +} + +.src-link { + margin-bottom: 15px; +} + +.src-link a { + /* font-size: 70%; */ + padding: 1px 4px; + text-decoration: none; + color: #5555bb; +} \ No newline at end of file diff --git a/latest/api/index.html b/latest/api/index.html new file mode 100644 index 0000000..d711e3f --- /dev/null +++ b/latest/api/index.html @@ -0,0 +1,2 @@ + +Struct 0.1.0 API documentation

Struct Api Documentation

Version: 0.1.0

Struct

A structural validation library for Clojure(Script)

\ No newline at end of file diff --git a/latest/api/promesa.core.html b/latest/api/promesa.core.html new file mode 100644 index 0000000..7777a55 --- /dev/null +++ b/latest/api/promesa.core.html @@ -0,0 +1,2 @@ + +promesa.core documentation

Promesa Api Documentation

Version: 1.1.1

promesa.core

alet

macro

(alet bindings & body)

all

(all promises)

Given an array of promises, return a promise that is fulfilled when all the items in the array are fulfilled.

any

(any promises)

Given an array of promises, return a promise that is fulfilled when first one item in the array is fulfilled.

await

(await & args)

bind

(bind p callback)

A chain helper for promises.

branch

(branch p success failure)

cancel!

(cancel! p)

Cancel the promise.

cancelled?

(cancelled? v)

Return true if v is a cancelled promise.

catch

(catch p f)(catch p type f)

Catch all promise chain helper.

chain

(chain p & funcs)

Like then but accepts multiple parameters.

delay

(delay t)(delay t v)

Given a timeout in miliseconds and optional value, returns a promise that will fulfilled with provided value (or nil) after the time is reached.

done?

(done? p)

Returns true if promise p is already done.

err

A short alias for error function.

error

(error f p)(error f type p)

Same as catch but with parameters inverted.

extract

(extract p)

Returns the current promise value.

finally

(finally p callback)

Attach handler to promise that will be executed independently if promise is resolved or rejected.

ICancellable

protocol

A cancellation abstraction.

members

-cancel

(-cancel _)

-cancelled?

(-cancelled? _)

IPromise

protocol

A basic future abstraction.

members

-bind

(-bind _ callback)

Chain a promise.

-catch

(-catch _ callback)

Catch a error in a promise.

-map

(-map _ callback)

Chain a promise.

IPromiseFactory

protocol

A promise constructor abstraction.

members

-promise

(-promise _)

Create a promise instance.

IScheduler

protocol

members

-schedule

(-schedule _ ms func)

IState

protocol

Additional state/introspection abstraction.

members

-extract

(-extract _)

Extract the current value.

-pending?

(-pending? _)

Retutns true if a promise is pending.

-rejected?

(-rejected? _)

Returns true if a promise is rejected.

-resolved?

(-resolved? _)

Returns true if a promise is resolved.

map

(map f p)

Apply a function to the promise value and return a new promise with the result.

mapcat

(mapcat f p)

Same as map but removes one level of promise neesting. Useful when the map function returns a promise instead of value.

In JS environment this function is analogous to map because the promise abstraction overloads the map operator.

pending?

(pending? p)

Returns true if promise p is stil pending.

promise

(promise v)

The promise constructor.

promise->str

(promise->str p)

promise?

(promise? v)

Return true if v is a promise instance.

promisify

(promisify callable)

Given a nodejs like function that accepts a callback as the last argument and return an other function that returns a promise.

rejected

(rejected v)

Return a rejected promise with provided reason.

rejected?

(rejected? p)

Returns true if promise p is already rejected.

resolved

(resolved v)

Return a resolved promise with provided value.

resolved?

(resolved? p)

Returns true if promise p is already fulfilled.

schedule

(schedule ms func)

Schedule a callable to be executed after the ms delay is reached.

In JVM it uses a scheduled executor service and in JS it uses the setTimeout function.

then

(then p f)

Same as map but with parameters inverted for convenience and for familiarity with javascript’s promises .then operator.

\ No newline at end of file diff --git a/latest/api/promesa.monad.html b/latest/api/promesa.monad.html new file mode 100644 index 0000000..d8fec47 --- /dev/null +++ b/latest/api/promesa.monad.html @@ -0,0 +1,2 @@ + +promesa.monad documentation

Promesa Api Documentation

Version: 1.1.1

promesa.monad

An optional cats integration.

\ No newline at end of file diff --git a/latest/api/promesa.protocols.html b/latest/api/promesa.protocols.html new file mode 100644 index 0000000..c84b432 --- /dev/null +++ b/latest/api/promesa.protocols.html @@ -0,0 +1,2 @@ + +promesa.protocols documentation

Promesa Api Documentation

Version: 0.8.1

promesa.protocols

ICancellablePromise

protocol

A cancellation abstraction for promises.

members

-cancel

(-cancel _)

Cancel promise.

-cancelled?

(-cancelled? _)

Check if promise is cancelled.

IPromise

protocol

A basic future abstraction.

members

-bind

(-bind _ callback)

Chain a promise.

-catch

(-catch _ callback)

Catch a error in a promise.

-map

(-map _ callback)

Chain a promise.

IPromiseFactory

protocol

A promise constructor abstraction.

members

-promise

(-promise _)

Create a promise instance.

IState

protocol

Additional state/introspection abstraction.

members

-extract

(-extract _)

Extract the current value.

-pending?

(-pending? _)

Retutns true if a promise is pending.

-rejected?

(-rejected? _)

Returns true if a promise is rejected.

-resolved?

(-resolved? _)

Returns true if a promise is resolved.

\ No newline at end of file diff --git a/latest/api/struct.core.html b/latest/api/struct.core.html new file mode 100644 index 0000000..5de8c82 --- /dev/null +++ b/latest/api/struct.core.html @@ -0,0 +1,2 @@ + +struct.core documentation

Struct Api Documentation

Version: 0.1.0

struct.core

valid-single?

(valid-single? data schema)

Analogous function to valid? that just validates single value.

valid?

(valid? data schema)

Return true if the data matches the schema, otherwise return false.

validate

(validate data schema)(validate data schema {:keys [strip], :or {strip false}, :as opts})

Validate data with specified schema.

This function by default strips all data that does not defined in schema, but this behavior can be changed passing {:strip false} as third argument.

validate!

(validate! data schema)(validate! data schema {:keys [message], :or {message "Schema validation error"}, :as opts})

Analogous function to the validate that instead of return the errors, just raise a ex-info exception with errors in case them are or just return the validated data.

This function accepts the same parameters as validate with an additional :message that serves for customize the exception message.

validate-single

(validate-single data schema)(validate-single data schema opts)

A helper that used just for validate one value.

\ No newline at end of file diff --git a/latest/index.html b/latest/index.html new file mode 100644 index 0000000..1fc8cf0 --- /dev/null +++ b/latest/index.html @@ -0,0 +1,623 @@ + + + + + + + +struct - Structural validation library + + + + + + +
+
+

Introduction

+
+
+

A structural validation library for Clojure and ClojureScript.

+
+
+

But with this differences:

+
+
+
    +
  • +

    No macros: validators are defined using plain data.

    +
  • +
  • +

    Dependent validators: the ability to access to already validated data.

    +
  • +
  • +

    Coersion: the ability to coerce incoming values to other types.

    +
  • +
  • +

    No exceptions: no exceptions used in the validation process.

    +
  • +
+
+
+

Based on similar ideas of +bouncer.

+
+
+

Project Maturity

+
+

Since struct is a young project there may be some API breakage.

+
+
+
+

Install

+
+

Just include that in your depencency vector on project.clj:

+
+
+
+
[funcool/struct "0.1.0"]
+
+
+
+
+
+
+

User guide

+
+
+

Quick Start

+
+

Let’s require the main struct namespace:

+
+
+
+
(require '[struct.core :as st])
+
+
+
+

Define a small schema for the example purpose:

+
+
+
+
(def +scheme+
+  {:name [st/required st/string]
+   :year [st/required st/number]})
+
+
+
+

You can observe that it consists in a simple map when you declare keys and +corresponding validators for that key. A vector as value allows us to put +more than one validator for the same key. If you have only one validator for the +key, you can omit the vector and put it as single value.

+
+
+

The same schema can be defined using vectors, if the order of validation +matters:

+
+
+

(def scheme + [[:name [st/required st/string]] + [:year [st/required st/number]]])

+
+
+

By default, all validators are optional so if the value is missing, no error +will reported. If you want make the value mandatory, you should use a specific +required validator.

+
+
+

And finally, start validating your data:

+
+
+
+
(-> {:name "Blood of Elves" :year 1994}
+    (st/validate +scheme+))
+;; => [nil {:name "Blood of Elves" :year 1994}]
+
+(-> {:name "Blood of Elves" :year "1994"}
+    (st/validate +scheme+))
+;; => [{:year ("must be a number")} {:name "Blood of Elves", :year "1994"}]
+
+(-> {:year "1994"}
+    (st/validate +scheme+))
+;; => [{:name ("this field is mandatory"), :year ("must be a number")} {}]
+
+
+
+

If only want to know if some data is valid or not, you can use the valid? predicate +for that purpose:

+
+
+
+
(st/valid? {:year "1994"} +scheme+)
+;; => false
+
+
+
+

The additional entries in the map will be striped by default, but this +can be turned off passing an additional flag as third argument:

+
+
+
+
(-> {:name "Blood of Elves" :year 1994 :foo "bar"}
+    (st/validate +scheme+))
+;; => [nil {:name "Blood of Elves" :year 1994}]
+
+(-> {:name "Blood of Elves" :year 1994 :foo "bar"}
+    (st/validate +scheme+ {:strip false}))
+;; => [nil {:name "Blood of Elves" :year 1994 :foo "bar"}]
+
+
+
+
+

Parametrized validators

+
+

Additionally to simple validators, other may require additional parameters +(e.g. in-range). This is how them can be passed to the validator:

+
+
+
+
(def schema {:num [[st/in-range 10 20]]})
+
+(st/validate {:num 21} schema)
+;; => [{:num ("not in range")} {}]
+
+(st/validate {:num 19} schema)
+;; => [nil {:num 19}]
+
+
+
+

Note the double vector, the outer denotes a list of validatiors and the inner +denotes a validator with patameters.

+
+
+
+

Custom messages

+
+

The builtin validators comes with default messages in human readable format, but +sometimes you may want to change them (e.g. for i18n purposes). This is how you +can do it:

+
+
+
+
(def schema
+  {:num [[st/in-range 10 20 :message "errors.not-in-range"]]})
+
+(st/validate {:num 21} schema)
+;; => [{:num ("errors.not-in-range")} {}]
+
+
+
+
+

Data coersions

+
+

Additionally to simple validation process, this library includes the facility +for coerce values and a collection of validators that matches over strings. Let +see some code:

+
+
+
Example attaching custom coersions
+
+
(def schema
+  {:year [[st/integer :coerce str]]})
+
+(st/validate {:year 1994} schema))
+;; => [nil {:year "1994"}]
+
+
+
+

From previous example, you can see that the data returned from the validation +process, the value is properly coerced with the specified coersion function.

+
+
+

Furthermore, this library comes with a collection of validators that already +has attached coersion function, and them serves just for validate paraeters +that comes in string format and convert later to the appropriate type:

+
+
+
+
(def schema {:year [st/required st/integer-str]
+             :id [st/required st/uuid-str]})
+
+(st/validate {:year "1994"
+              :id "543e7472-6624-4cb5-b65e-f3c341843d0f"}
+             schema)
+;; => [nil {:year 1994, :id #uuid "543e7472-6624-4cb5-b65e-f3c341843d0f"}]
+
+
+
+

For facilitate this operation, it there validate! function that receives the +data and scheme and returns the resulting data. If data not matches the schema +an exception will be raised using ex-info clojure facility:

+
+
+
+
(st/validate! {:year "1994" :id "543e7472-6624-4cb5-b65e-f3c341843d0f"} schema)
+;; => {:year 1994, :id #uuid "543e7472-6624-4cb5-b65e-f3c341843d0f"}
+
+
+
+
+

Builtin Validators

+
+

This is the table with available builtin validators:

+
+ + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1. Builtin Validators
IdentifierCoersionDescription

struct.core/keyword

no

Validator for clojure’s keyword

struct.core/uuid

no

Validator for UUID’s

struct.core/uuid-str

yes

Validator for uuid strings with coersion to UUID

struct.core/email

no

Validator for email string.

struct.core/required

no

Marks field as required.

struct.core/number

no

Validator for Number.

struct.core/number-str

yes

Validator for number string.

struct.core/integer

no

Validator for integer.

struct.core/integer-str

yes

Validator for integer string.

struct.core/boolean

no

Validator for boolean.

struct.core/boolean-str

yes

Validator for boolean string.

struct.core/string

no

Validator for string.

struct.core/string-str

yes

Validator for string like.

struct.core/in-range

no

Validator for a number range.

struct.core/member

no

Validator for check if a value is member of coll.

struct.core/positive

no

Validator for positive number.

struct.core/negative

no

Validator for negative number.

struct.core/function

no

Validator for IFn interface.

struct.core/vector

no

Validator for clojure vector.

struct.core/map

no

Validator for clojure map.

struct.core/set

no

Validator for clojure set.

struct.core/coll

no

Validator for clojure coll.

struct.core/every

no

Validator for check if pred match for every item in coll.

`struct.core/identical-to

no

Validator for check that value is identical to other field.

+
+

Additional notes:

+
+
+
    +
  • +

    number-str coerces to java.lang.Double or float (cljs)

    +
  • +
  • +

    boolean-str coerces to true ("t", "true", "1") or false ("f", "false", "0").

    +
  • +
  • +

    string-str coerces anything to string using str function.

    +
  • +
+
+
+
+

Define own validator

+
+

As is mentioned previously, the validators in struct library are defined using plain +hash-maps. As example, this is how the builtin integer validator is defined:

+
+
+
+
(def integer
+  {:message "must be a integer"
+   :optional true
+   :validate integer?}))
+
+
+
+

If the validator needs access to the previous already validated data, the :state key +should be present with true as value. Let see the identical-to validator as example:

+
+
+
+
(def identical-to
+  {:message "does not match"
+   :optional true
+   :state true
+   :validate (fn [state v ref]
+               (let [prev (get state ref)]
+                 (= prev v)))})
+
+
+
+

Validators that acces to the state, receives an other argument with the state to validator +function.

+
+
+
+
+
+

Developers Guide

+
+
+

Contributing

+
+

Unlike Clojure and other Clojure contrib libs, does not have many restrictions for +contributions. Just open a issue or pull request.

+
+
+
+

Get the Code

+
+

struct is open source and can be found on +github.

+
+
+

You can clone the public repository with this command:

+
+
+
+
git clone https://github.com/funcool/struct
+
+
+
+
+

Run tests

+
+

To run the tests execute the following:

+
+
+

For the JVM platform:

+
+
+
+
lein test
+
+
+
+

And for JS platform:

+
+
+
+
./scripts/build
+node out/tests.js
+
+
+
+

You will need to have nodejs installed on your system.

+
+
+
+

License

+
+

struct is under public domain:

+
+
+
+
This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
+
+
+
+
+
+
+ + + \ No newline at end of file From ea2b6ba36f5f05bfeb1d17c9ba8334dde3c78af4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 3 May 2016 08:14:23 +0200 Subject: [PATCH 2/9] Generate documentation --- latest/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/latest/index.html b/latest/index.html index 1fc8cf0..f5ab8d1 100644 --- a/latest/index.html +++ b/latest/index.html @@ -5,7 +5,7 @@ -struct - Structural validation library +struct - validation library for Clojure(Script) @@ -91,7 +97,7 @@

struct - validation library for Clojure(Script)

  • Quick Start
  • Parametrized validators
  • Custom messages
  • -
  • Data coersions
  • +
  • Data coercions
  • Builtin Validators
  • Define your own validator
  • @@ -126,7 +132,7 @@

    Introduction

    Dependent validators: the ability to access to already validated data.

  • -

    Coersion: the ability to coerce incoming values to other types.

    +

    Coercion: the ability to coerce incoming values to other types.

  • No exceptions: no exceptions used in the validation process.

    @@ -146,11 +152,11 @@

    Project Matur

    Install

    -

    Just include that in your depencency vector on project.clj:

    +

    Just include that in your dependency vector on project.clj:

    -
    [funcool/struct "1.0.0"]
    +
    [funcool/struct "1.1.0"]
    @@ -300,14 +306,14 @@

    Custom messages
    -

    Data coersions

    +

    Data coercions

    In addition to simple validations, this library includes the ability to coerce values, and a collection of validators that matches over strings. Let’s see some code:

    -
    Example attaching custom coersions
    +
    Example attaching custom coercions
    (def schema
       {:year [[st/integer :coerce str]]})
    @@ -318,11 +324,11 @@ 

    Data coersions

    Looking at the data returned from the validation -process, one can see that the value is properly coerced with the specified coersion function.

    +process, one can see that the value is properly coerced with the specified coercion function.

    This library comes with a collection of validators that already -have attached coersion functions. These serve to validate parameters +have attached coercion functions. These serve to validate parameters that arrive as strings but need to be converted to the appropriate type:

    From 306372dea6bfa83cbc93b4485509a6801c3c1689 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 11 Jan 2018 12:00:51 +0100 Subject: [PATCH 8/9] Generate documentation --- latest/api/index.html | 2 +- latest/api/struct.core.html | 4 +++- latest/index.html | 40 ++++++++++++++++++------------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/latest/api/index.html b/latest/api/index.html index e1c8855..1cd28bc 100644 --- a/latest/api/index.html +++ b/latest/api/index.html @@ -1,2 +1,2 @@ -Struct 1.1.0 API documentation

    Struct Api Documentation

    Version: 1.1.0

    Struct

    A structural validation library for Clojure(Script)

    \ No newline at end of file +Struct 1.2.0 API documentation

    Struct Api Documentation

    Version: 1.2.0

    Struct

    A structural validation library for Clojure(Script)

    \ No newline at end of file diff --git a/latest/api/struct.core.html b/latest/api/struct.core.html index 0548e70..7415394 100644 --- a/latest/api/struct.core.html +++ b/latest/api/struct.core.html @@ -1,2 +1,4 @@ -struct.core documentation

    Struct Api Documentation

    Version: 1.1.0

    struct.core

    valid-single?

    (valid-single? data schema)

    Analogous function to valid? that just validates single value.

    valid?

    (valid? data schema)

    Return true if the data matches the schema, otherwise return false.

    validate

    (validate data schema)(validate data schema {:keys [strip], :or {strip false}, :as opts})

    Validate data with specified schema.

    This function by default strips all data that does not defined in schema, but this behavior can be changed passing {:strip false} as third argument.

    validate!

    (validate! data schema)(validate! data schema {:keys [message], :or {message "Schema validation error"}, :as opts})

    Analogous function to the validate that instead of return the errors, just raise a ex-info exception with errors in case them are or just return the validated data.

    This function accepts the same parameters as validate with an additional :message that serves for customize the exception message.

    validate-single

    (validate-single data schema)(validate-single data schema opts)

    A helper that used just for validate one value.

    \ No newline at end of file +struct.core documentation

    Struct Api Documentation

    Version: 1.2.0

    struct.core

    valid-single?

    (valid-single? data schema)

    Analogous function to valid? that just validates single value.

    valid?

    (valid? data schema)

    Return true if the data matches the schema, otherwise return false.

    validate

    (validate data schema)(validate data schema {:keys [strip], :or {strip false}, :as opts})

    Validate data with specified schema.

    +

    This function by default strips all data that does not defined in schema, but this behavior can be changed passing {:strip false} as third argument.

    validate!

    (validate! data schema)(validate! data schema {:keys [message], :or {message "Schema validation error"}, :as opts})

    Analogous function to the validate that instead of return the errors, just raise a ex-info exception with errors in case them are or just return the validated data.

    +

    This function accepts the same parameters as validate with an additional :message that serves for customize the exception message.

    validate-single

    (validate-single data schema)(validate-single data schema opts)

    A helper that used just for validate one value.

    \ No newline at end of file diff --git a/latest/index.html b/latest/index.html index 612bd65..a4de238 100644 --- a/latest/index.html +++ b/latest/index.html @@ -4,7 +4,7 @@ - + struct - validation library for Clojure(Script)