ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
ur5us has quit [Ping timeout: 255 seconds]
renich has joined #crystal-lang
<renich> Hello! How can I validate an XML file against an XSD?
Sankalp has quit [Ping timeout: 256 seconds]
Sankalp has joined #crystal-lang
<FromGitter> <Blacksmoke16> idt the stdlib has those libxml2 methods bound
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> renich: Here you go, it's very low level as im just using the bindings directly, referencing ⏎ ⏎
<FromGitter> <Blacksmoke16> i get no output using the example file and XSD from W3 schools, but setting one of the quantities to `-1` it prints `"Element 'quantity': '-1' is not a valid value of the atomic type 'xs:positiveInteger'.\n"` so seems to work
<renich> Blacksmoke16: thanks
<renich> Pretty cool!
<FromGitter> <Blacksmoke16> could open an issue on GH about it. Maybe that's something they would want in stdlib given we're binding libXML2 anyway? :shrug:
<renich> That should definitelly go in stdlib. It's super useful.
ur5us has joined #crystal-lang
<renich> For example, in México, in order to issue "electronic invoices" to our IRS (SAT), we need to validate against xsd.
<renich> For example, validate against something like this:
<FromGitter> <Blacksmoke16> useful yea, but then comes the question of the API/implementation. I.e. might be a lot and better suited to a shard
<FromGitter> <Blacksmoke16> deff worth opening an issue for the discussion id say
<renich> Blacksmoke16: OK, I will.
<renich> BTW, I am getting a memory violation.
<renich> Blacksmoke16: done. #12131
<FromGitter> <Blacksmoke16> Yea my example doesn't have any error handling
<FromGitter> <Blacksmoke16> Probably would need to add some of that in like in the SO post
<FromGitter> <Blacksmoke16> To see what the actual issue is
_ht has joined #crystal-lang
ur5us has quit [Ping timeout: 248 seconds]
_ht has quit [Remote host closed the connection]
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 248 seconds]
tsujp has joined #crystal-lang
<FromGitter> <paulocoghi> Hello everyone! ⏎ ⏎ Do you know how to inform a functions parameter type is of a specific NamedTuple format? Or it isn't necessary?
<FromGitter> <paulocoghi> For example:
<FromGitter> <paulocoghi> ```def update(data : NamedTuple( id: Int32, json : String ) ) ⏎ end``` []
<FromGitter> <Blacksmoke16> does that not work?
<FromGitter> <paulocoghi> No
<FromGitter> <Blacksmoke16> whats the error?
<FromGitter> <paulocoghi> `syntax error in 'STDIN:62:44': expected ')' or named argument, not json`
<FromGitter> <Blacksmoke16> and how are you calling the method
<FromGitter> <Blacksmoke16> ah nvm i see the issue
<FromGitter> <paulocoghi> Hmmm, maybe this is the reason. The function signature was different and I was updating it. The calling line wasn't updated
<FromGitter> <Blacksmoke16> it should be `json: String` not `json : String`
<FromGitter> <paulocoghi> Ah, ok!
<FromGitter> <paulocoghi> Thanks a lot!
<FromGitter> <Blacksmoke16> tho i will say named tuples arent really meant to be used to model data as something you pass around
<FromGitter> <paulocoghi> > ah nvm i see the issue ⏎ ⏎ Exactly. This was the issue
<FromGitter> <paulocoghi> Thanks a lot again!
<FromGitter> <Blacksmoke16> consider using a struct like `record Data, id : Int32, json : String` then `update(data : Data)` or something like that
<FromGitter> <paulocoghi> Interesting! I will do that :)
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
Vexatos has quit [Ping timeout: 260 seconds]
Stephie has quit [Ping timeout: 258 seconds]
<renich> Hey Blacksmoke16, found where to submit errata for the book:
<FromGitter> <Blacksmoke16> 👍 thanks
renich has quit [Remote host closed the connection]
_ht has joined #crystal-lang
Vexatos has joined #crystal-lang
Stephie has joined #crystal-lang
onyx has joined #crystal-lang
<FromGitter> <> You're welcome.
hightower2 has joined #crystal-lang
_ht has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
onyx has quit [Read error: Connection reset by peer]