-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type coercion of attributes #236
Comments
So I think that type coercion is only a good idea for accessors because it sounds like your instances subclass all validated schemas, right?
In python-experimental I make instances subclass all validated schemas and provide acessor methods for format data types. And one also needs to allow format to be applied on AnyType schemas like in: |
Hi Justin, good to hear from you.
I'm not sure how you mean this. Do you mean object property accessors? I think this would apply equally to any instance.
JSI instances are instances of mixins corresponding to every schema which describes them. This doesn't depend on validation, mostly, e.g. (This isn't really on topic related to type coersion, but worth clarifying I think.)
This might be the way to go. So far this is just some thoughts thrown together in an issue that I might implement eventually, so haven't figured out what kind of interface would work, allowing access to coerced vs. raw instance data.
I'm not sure what an AnyType schema means, and at a glance I'm not sure what that PR is doing (far too large for me to grok ... or even to tell what's generated code vs the actual origin of all the changes). |
An AnyType schema is an empty schema {} Here is an example of the accessor method
|
I was trying to point out these type unset (AnyType) + format example in my above PR
|
Base#[]
could coerce children's types, based onformat
keyword or other indications of a more natural representation. e.g.:format: date-time
coerces to a rubyTime
format: uuid
coerces to UUIDTools::UUIDtype: array
+uniqueItems: true
coerces toSet
?Base#==
/#hash
to disregard pointer). I could skip adding nodes whose content is already in the Set, but that sounds bad.Set
is not appropriate ifitems
is an array (orprefixItems
/postfixItems
used, later)more thoughts:
Base#[]=
must coerce opposite toBase#[]
. instance data must stay as json types.The text was updated successfully, but these errors were encountered: