Questions tagged [plumatic-schema]

A Clojure(Script) library for declarative data description and validation. Originally known as Prismatic-Schema.

A Clojure(Script) library for declarative data description and validation.

Schema enables Clojure developers to neatly specify the form of function inputs and outputs in the function metadata. This allows the library to explain and validate a function's usage, regardless of the complexity of data types.

62 questions
9
votes
1 answer

Global flag to turn on/off validation in Prismatic/Schema?

During development I would like to enable validation for all functions that are defined with schema.core/defn, instead of having to annotate them with :^:always-validate. Is this possible with this library? Something like this doesn't work, probably…
Michiel Borkent
  • 34,228
  • 15
  • 86
  • 149
8
votes
1 answer

Implicit or Explicit Many to Many relationship in prisma

When should you use a implicit many to many relationship in prisma and when explicit many to many relationship ? Do they have any trade-off or anything that should be noted
Darshan V
  • 198
  • 9
8
votes
1 answer

:body-params vs :form-params in compojure-api

What's the difference between using :body-params and :form-params in practice when creating an API using compojure-api? For example: (POST* "/register" [] :body-params [username :- String, password :- String] …
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
6
votes
2 answers

Include relationship when querying node using Prisma generated wrapper

I am following the GraphQL Prisma Typescript example provided by Prisma and created a simple data model, generated the code for the Prisma client and resolvers, etc. My data model includes the following nodes: type User { id: ID! @unique …
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126
6
votes
1 answer

Non-required arguments in compojure-api/schema/swagger?

When I have a definition of an API like this: (POST* "/register" [] :body-params [username :- String, password :- String, name :- String] (ok))) what's the appropriate way of making name optional? Is…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
4
votes
1 answer

Using Plumatic Schema to coerce to bigdec

I have incoming data of the type {:loan/amount 1200}. Would it be possible to use plumatic Schema to coerce this to {:loan/amount 1200M}, ie coercing numbers (or even strings of digits) to bigdecimals? I don't how to define a new data type (like…
claj
  • 5,172
  • 2
  • 27
  • 30
4
votes
1 answer

Why can't I use regular expressions to validate strings as map keys?

In my Clojure project, I have these: :dependencies [ [org.clojure/clojure "1.8.0"] [prismatic/schema "1.0.5"]] This is considered valid: (require '[schema.core :as s]) (def pos (s/pred #(re-matches #"\d+,\d+" %))) (s/validate pos "0,0") ;…
T.W.R. Cole
  • 4,106
  • 1
  • 19
  • 26
4
votes
1 answer

Optional element in sequence

I'm trying to match following sequences using Prismatic/Schema: [{:n "some text"}] ; => valid and [{:k "some text"} {:n "some text"}] ; => valid What I have tried: (s/def Elem3 {:k s/Str}) (s/def Elem2 {:n s/Str}) (s/def Elem [(s/optional…
foki
  • 8,624
  • 6
  • 33
  • 32
4
votes
1 answer

How to inspect ValidationError raised during Prismatic Schema coercion?

As a result of creating a Schema coercer and then trying to coerce a set of data I get as a result: #schema.utils.ErrorContainer{:error #} How do I get an explanation of what the actual…
David Collie
  • 665
  • 2
  • 7
  • 21
4
votes
1 answer

Is it possible to use Prismatic schema.core/maybe in a Clojure function precondition?

I'm trying to use Prismatic schema.core/maybe in a precondition for a function taking an optional argument opts, but it seems to always throw an AssertionError when I call the function with no opts: (require '[schema.core :as schema]) (defn foo [&…
Josh Glover
  • 25,142
  • 27
  • 92
  • 129
3
votes
1 answer

Prisma data modeling has many and belongs to

I have a prisma data model that consists of a root Category and a Subcategory. A Category has many Subcategories and a Subcategory belongs to one Category. My model looks like this: type Category { id: ID! @unique createdAt: DateTime! …
Dan Ramos
  • 1,092
  • 2
  • 19
  • 35
3
votes
1 answer

How do I generate user friendly validation messages with plumatic/schema?

I would like to be able to generate user-friendly or specify custom error messages for validation errors in these schemas: (def Uuid (s/constrained String #(re-matches #"^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"…
Freid001
  • 2,580
  • 3
  • 29
  • 60
3
votes
1 answer

cannot validate values with string keys in map using clojure schema library

I tried validating a map using the prismatic/schema library for clojure. here is my shape (require '[schema.core :as s]) (def d {"a" s/Str "b" s/Int}) When I tried to validate it against a map, it throws the following exception (s/validate d {"a"…
draklor40
  • 453
  • 7
  • 17
3
votes
1 answer

What is the difference between body and body-params in compojure-api?

In compojure-api I noticed this two ways of specifying the API of a resource: (POST* "/register" [] :body [user UserRegistration] (ok))) and (POST* "/register" [] :body-params [username :- String, password :- String] …
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
3
votes
0 answers

How to define prismatic schema for interleaved types?

Lets assume I have the following sequence: '[ SomeMandatorySymbol AnotherMandatorySymbol 123 "mandatory string" 2 "a" 9 "c" 11 "f" 23 "x" ] e.g. [(one Symbol) (one Symbol) (one Int) (one Str) ... ] What…
Lambder
  • 2,953
  • 1
  • 26
  • 20
1
2 3 4 5