lundi 2 mars 2020

Transform data between ember-changeset property and Input @value

I have an ember-data model, with some non-string properties.

I have an edit form, where I am using emberjs's Input helper to allow the user to edit it, and then I am using ember-changeset-validations to only update the underlying model if the user input is valid.

What I am confused about at the moment, is how can I transform the data coming from the Input helper (which comes back as a string) into the proper type for my ember-changeset-validations to work properly?

I feel like I need another helper in-between that does the serialization/deserialization between the raw data type and a string. But I'm not sure if this is possible.

Another option I can think of is create new components that inherit the Input helper component, one for each specific data type that I have...but that seems like overkill.




Aucun commentaire:

Enregistrer un commentaire