This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-09
Channels
- # aws (51)
- # beginners (57)
- # calva (10)
- # chlorine-clover (7)
- # cider (20)
- # clj-kondo (55)
- # clojure (43)
- # clojure-europe (9)
- # clojure-italy (1)
- # clojure-nl (5)
- # clojure-spec (8)
- # clojure-uk (71)
- # clojurescript (33)
- # core-async (22)
- # cursive (20)
- # datomic (3)
- # emacs (8)
- # figwheel-main (8)
- # fulcro (13)
- # garden (2)
- # graalvm (60)
- # graphql (26)
- # jobs (6)
- # joker (6)
- # kaocha (2)
- # lambdaisland (5)
- # malli (36)
- # off-topic (9)
- # portkey (15)
- # re-frame (3)
- # reagent (25)
- # remote-jobs (4)
- # spacemacs (3)
- # sql (111)
- # tree-sitter (29)
- # uncomplicate (3)
- # xtdb (2)
@ikitommi https://github.com/cgrand/seqexp will need some adjustments if we want to use it in Malli:
• Its implementation is not cross platform.
• The maps returned by se/exec
contain the keyed groups in the middle of :rest
and :match
, that could be a problem when the keys of those groups are controlled by Malli’s users.
@vincent.cantin ok. The cross-platform should be doable, ig Cristophe takes PRS (there should be an issue about that), not sure about the second. If that is not a good base lib to use, do you have plans on using something else? or from scratch?
I started to scratch my head about a new impl this morning. What's next depends on what features we want to offer the users.
I think that an optimized & naive impl might be faster on most use cases compared to a general algorith that works in theory faster and cover all edge cases. I would like to put them to a benchmark on realworld usages.
What kind of edge cases would not be covered using a naive impl? Benchmarks most welcome!
All the use cases would be covered by using a naive impl. Some edge cases might have a high computational cost in a naive impl while a smarter impl would mitigate the cost of their parsing. The edge cases I am thinking about are consecutive sequences of variable length. But I am not sure if it is a real concern or my imagination.
did a quick draft of a swappable default registry: idea that the default registry could be bootstrapped into something that satisifes m/Registry
protocol. There could be malli.mutable
with an alternative impl using a extra atom to look for the schemas and malli.mutable/register!
to register schemas into that. This would be a simple -> easy helper, already not happy with that. Comments welcome https://github.com/metosin/malli/pull/188
;; JVM started with -Dmalli.core.registry=malli.mutable/registry
(require '[malli.core :as m])
(require '[malli.mutable :as mm])
(mm/register! ::age [:and int? [:> 18]])
(m/validate ::age 20)
; => true
I also don’t like the idea to lose the property of working with immutable values.
I would suggest users who don’t want to have to pass the registry as option to Malli all the time to just create their own wrapper functions.
;; in my-ns
(defn validate [schema data options]
(m/validate schema data (assoc options :registry my-registry)))
I was facing the same situation in projects which use Vrac, and I used the wrapper pattern everywhere. It’s really not a big deal and it keep the satisfaction of working in an environment where we don’t even have to think about the side effects.
Is cross-platform regex even possible? Beyond basics I don’t think JS/Java/C# regex engines are even close to compatible with each other.
we are talking about validating data structures, not string content.
are recursive schemas possible w/ malli?
e.g. defining a schema for a {:name "something" :kids [{:name "something" :kids [....]}]}
it does appear such things are possible in spec: https://gist.github.com/bhb/6cfcb3b38757442aec4ba5db46148699
sorry just reading the whole of that linked issue and I see you guys are putting a lot of thought and effort into your approach so I will wait and see!
I am about to start to try generating Malli schemas from PostgreSQL metadata. Very curious how far I can take this. If I find a way to store additional custom metadata in the database, I could end up generating 90% of a form simply by converting Postgres metadata, the rest being the layout.
Just curious, what kind of metadata you mean? PostgreSQL’s information schema is already quite extensive…
I have some code that does the same. I wasn't able to find a good solution for restricting string length. Maybe that has changed in the meantime.
In PostgreSQL `TEXT` is string with infinite length (_=<https://wiki.postgresql.org/wiki/FAQ#What_is_the_maximum_size_for_a_row.2C_a_table.2C_and_a_database.3F|1GB> because that is any field’s maximum size_); string with specific maximum should be done with `VARCHAR` columns in which case `information_schema.columns` `character_maximum_length` has the column’s size limit information.
Assuming I’ve understood correctly, I seem to have a lousy track record on that part this week… 🙂
The JDBC API also offers metadata, but probable less than direct PostgreSQL use. Prior art in spec land: • https://github.com/tatut/specql • https://github.com/viesti/table-spec
@U2APCNHCN the specql implementation might be really good help in looking what postgresql offers
JDBC https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/DatabaseMetaData.html is very extensive, haven’t tested but it seems with https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,java.lang.String,java.lang.String,java.lang.String) COLUMN_SIZE
has the maximum length; the same TEXT/VARCHAR size detail as described above of course still applies.
yup, although I have a feeling that it might lack info on postgresql specific extensions
Yes, DatabaseMetaData is what I currently use. My showstopper right now is that I can't get the data transformations to work...