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
1
vote
1 answer

Prisma : Models and Relationship 1-n

I have two tables User and Tasks and a user can have many tasks, however i want a query to return a particular task, fetching details for the task, with author and assigned to users from the user table, usually would be done using aliases. DB is…
1
vote
0 answers

Where do you pass the :ignore-missing-mapping? keyword in reitit swagger to ignore unconvertable schemas?

I've been following the ring-swagger server.clj example to set my own http server but with prismatic/schema coercion. Everything works just fine when my leafs are of basic type such as s/Str or s/Int, but I can't get it to work with (s/pred…
D.Ginzbourg
  • 490
  • 7
  • 22
1
vote
1 answer

Prismatic/Schema require key dependency?

I am using plumatic/schema with my compojure-api to validate the input for an endpoint. I have two keys in my schema: Field1 & Field2. I want to be able to define a rule for my schema which for example says: WHEN Field1 = "AA" THEN Field2 is…
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
vote
0 answers

Trouble building clara rules dynamically using instaparse

I followed this example Insta Declarative DSL where we use Clara with instaparse to use a DSL and generate rules. everything works for me as expected but one issue. I am not able to access the variable binding from the condition expressing in lhs…
1
vote
1 answer

how to use plumatic schema to define a function that takes an argument that can be 2 or more different types?

I can't figure out how to use s/either or s/conditional as part of the input list. Would like to do something like this: (s/defn parse-int :- s/Int [input :- ; either s/Int or s/Str] ; if s/Int input ; if s/Str (read-string…
marathon
  • 7,881
  • 17
  • 74
  • 137
1
vote
2 answers

Access datatypes in graphql server from prisma generated client

I'm running prisma side by side with my graphql application API. I can run prisma generate which produces the client side code and everything is great. However a majority of my endpoints on my application API are nothing more than a proxy to the…
Dan Ramos
  • 1,092
  • 2
  • 19
  • 35
1
vote
1 answer

Mutation doesn't work GraphQL, Prisma, Yoga

How to add User in this example? I try to use mutation in all ways but doesn't work. type User { masterId: Int name: String surname: String address: Address } type Address { street: String flat: Int city: String country:…
konkret12345
  • 87
  • 2
  • 8
1
vote
0 answers

How to assign a predicate to extra-validator-fn?

How would I assign a predicate to each check in the extra-validator-fn of the following schema defrecord: (s/defrecord Item [type :- (s/enum :solid :liquid) unit :- (s/enum :kg :ml)] (s/fn [{:as this :keys [type unit]}] …
Freid001
  • 2,580
  • 3
  • 29
  • 60
1
vote
2 answers

Plumatic Schema for keyword arguments

Say we have a function get-ints with one positional argument, the number of ints the caller wants, and two named arguments :max and :min like: ; Ignore that the implementation of the function is incorrect. (defn get-ints [nr & {:keys [max min] :or…
Rovanion
  • 4,382
  • 3
  • 29
  • 49
1
vote
1 answer

Adding Syntactic Sugar to Make Prismatic Schema Look Like Core.Typed/Haskell

Consider the way core.typed annotates a function: (t/ann typed-function [t/Str :-> t/Str]) Now consider the way Prismatic Schema annotates a function: (s/defn schema-function :- s/Str [arg :- s/Str] arg) Personally, I find the way…
George
  • 6,927
  • 4
  • 34
  • 67
1
vote
1 answer

Default values for prismatic/schema coerce instead of error messages

Using prismatic/schema coerce is it possible to have default values when the coercion fails instead of the error message. I have a value in a csv file which could be blank (nil) or s/Int. At the moment with the below code I get this for blanks: …
sectornitad
  • 973
  • 3
  • 11
  • 20
1
vote
1 answer

How to get 'at-least' schema?

By 'at-least' I mean schema that will ignore all disallowed-key errors. Consider the following snippet: (require '[schema.core :as s]) (def s {:a s/Int}) (s/check s {:a 1}) ;; => nil (check passed) (s/check s {:a 1 :b 2}) ;; => {:b…
OlegTheCat
  • 4,443
  • 16
  • 24
1
vote
1 answer

Prismatic schema coercion - renaming map key

I'm trying to coerce a map using prismatic-schema (1.0.4) I'm trying to coerce {:a 1} to {:b 1} Using a custom matcher with the schema: {:b s/Int} But this code isn't working: (require '[schema.core :as s]) (require '[schema.coerce :as…
Eric
  • 2,268
  • 2
  • 16
  • 24
1
vote
1 answer

Clojure prismatic/schema defrecord no enum runtime validation?

When using prismatic/schema, validation of enum on defrecord doesn't work, as shown here: (s/defrecord Action [type :- (s/enum :a :b)]) #'user/strict-map->Action user> (Action. "3") ; this should fail #user.Action{:type "3"} user>…
Nick
  • 167
  • 3
  • 9
1
vote
4 answers

Prismatic schema: removing unanticipated keys

My API is receiving some JSON data from the client. I would like to use Schema to perform validation and coercion on the data I receive, but with one additional requirement: if there is any map key that is not described in the schema, ignore and…
Valentin Waeselynck
  • 5,950
  • 26
  • 43