mbj / morpher

Transformation of ruby data-structures with optionally traced evaluation
MIT License
4 stars 1 forks source link

Validations example #9

Closed grk closed 3 years ago

grk commented 10 years ago

As discussed on twitter, here's what I'd like to see an example for:

Given a hash

{
  "one" => "two",
  "foo" => ["bar", "baz"]
}

I'd like to validate, without transforming (I need the hash as output anyway) that keys "one" and "two" are present, no other keys are present, and that for key "one", only string values are allowed, and for the key "foo" only an array of strings is allowed.

thanks :)

blambeau commented 10 years ago

Can't resist providing a Q solution here. @mbj how is morpher-qlang going?

{ one: .String, foo: [.String] }
mbj commented 10 years ago

@blambeau No OSS time, sorry :(

snusnu commented 10 years ago

I left a related comment at https://github.com/mbj/morpher/issues/10#issuecomment-38174627

mbj commented 3 years ago

I'm closing this as I'm unlikely to put up examples any time soon.