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

ClassNotFoundException when using instance? on a defrecord type in Clojure

I've written a function that selects only the keys of a map that are named in a specific schema: (ns foo.schema (:require [schema.core :as s])) (defn select-schema "Given a schema and a map m, selects only the keys of m that are named in the…
Josh Glover
  • 25,142
  • 27
  • 92
  • 129
0
votes
0 answers

Prisma raw date query returns no result with JS date Object but has result with date string

I have a raw query (postgresDb) with date input const orderStatArr: any = await this.prismaService .$queryRaw`select sum(tempt.totalAmount), count(tempt."orderId"), orders."paystat" as paystat from (select sum(items.count * items.amount) as…
Jay
  • 336
  • 1
  • 4
  • 15
0
votes
1 answer

Prisma create custom function in schema

I have a mongo collection where there is a field called amount. What I want is whenever I ask for the amount I want it divided by 100. The Django equivalent of it is a custom function inside the model. I have done the same like this class…
Harsh Gupta
  • 527
  • 1
  • 3
  • 13
0
votes
1 answer

How to define unique constraint for scalar list?

I created a scalar list tags in Post model. I want only unique tags in the list. How to do that? Post model:
0
votes
0 answers

Upsert in prisma without ID creates duplicate records (promise error?)

I need to insert records in a PG database from a json file with 500k records. Since the file is huge I'm creating a Read Stream and using JSONStream.parse to send json objects over to pipe. So far so good. This is not the problem, I'm just providing…
theRonny
  • 385
  • 5
  • 20
0
votes
1 answer

One-to-many and may-to-many relation between two prisma model

I am working on a side project and I came to an issue that I'm not sure how to solve. I have created two models, one for User and one for Project. The relation between them is many-to-many, as many users can have many projects, but i would also like…
Miloslavc
  • 127
  • 2
  • 7
0
votes
1 answer

validate schema with key and value using plumatic schema

I'm trying to do a validation for key value in a vector using plumatic-schema but the error message is not clear for me, here's what I'm trying to do: ;validating array with maps, it works (s/validate [{}] [{} {}]) => [{} {}] ;validating array with…
Paulo Victor
  • 3,814
  • 2
  • 26
  • 29
0
votes
0 answers

Access input in GraphQL Prisma Directive

I have a use case where in I want to access query parameter/arguments in the directive. Following is the schema. user(where: UserWhereUniqueInput!): User @isAuthenticated Query that is fired from playground user(where:{id: "test001"}){id…
Niks
  • 885
  • 1
  • 7
  • 17
0
votes
0 answers

Creating record constructors that check for schema in Clojure

Hello fellow Clojurians, it is known that Clojure's defrecords do not respect type hints and any type of data can be put in record fields. I am looking for a way to restrict the fields of records in Clojure. I started experimenting with the…
erdos
  • 3,135
  • 2
  • 16
  • 27
0
votes
1 answer

Expression for "a member in set" with plumatic Schema

I want to write a schema where an element e in a data structure can be any member in a set S of items; e ∈ S. With Clojure Spec this is expressed with a set like: (spec/def ::key-set #{:subprocess :leiningen :nrepl}) (gen/sample (spec/gen…
Rovanion
  • 4,382
  • 3
  • 29
  • 49
0
votes
2 answers

Can one make a predicate function from a Plumatic Schema?

I want to make a predicate function that when something matches schema X returns true, else false.
Rovanion
  • 4,382
  • 3
  • 29
  • 49
0
votes
1 answer

Generate from regular expression with Plumatic Schema generators

Regexes seem to be accepted schemas: (require '[schema.core :as schema]) (schema/validate #"^..$" "hi") ; => "hi" But schema-generators can't seem to generate from them: (require '[schema-generators.generators :as gen]) (gen/generate #"^..$") ;…
Rovanion
  • 4,382
  • 3
  • 29
  • 49
0
votes
1 answer

compojure-api return value schema or error

compojure-api allows you to define the return schema: (s/defschema Pizza {:name s/Str}) (GET "/pizza/:id" [id] :return Pizza :summary "returns a Pizza" (ok (get-pizza id))) My issue is when the get-pizza fn returns a 404 {:status 404 :body…
kittyminky
  • 478
  • 6
  • 27
0
votes
1 answer

In Compojure-api how can I apply schema validation to the form-params of a particular route?

From the docs compojure-api... Given (s/defschema Pizza {:name s/Str :size (s/enum :L :M :S) :origin {:country (s/enum :FI :PO) :city s/Str}}) You can later in your code do something like: (defapi app ... ... (POST* "/pizza" [] …
Naruto Sempai
  • 6,233
  • 8
  • 35
  • 51
0
votes
1 answer

Using clojure.core/Extend with Prismatic schema I get different behavior of s/protocol in s/validate and in s/with-fn-validation

I'm trying to validate the protocol of an instance of defrecord that I generate dynamically using clojure.core/extend Below You can see that satisfies returns true and (s/validate (s/protocol ...)) doesn't throw exception, but if I run…
tangrammer
  • 3,041
  • 17
  • 24