Date pickers
Closed this issue · 9 comments
We have some fields with string
type but formatted as date
or date-time
. However, the returned output of the schema is t.String
for those fields. Should we add support for t.Date
when the format is date
or similar?
If so, we're sending a PR tomorrow.
isn't covered by the registerFormat
API? https://github.com/gcanti/tcomb-json-schema#registerformatformat-string-predicate-x-any--boolean-void
Mmm, I don't think so, this is what we get using displayName
:
Struct{Arrival: ?{String | isDateTime}, Departure: {String | isDate}, Phone number: ?Number}
Maybe we need to set the right template here: https://github.com/APSL/tcomb-form-native-json-schema/blob/master/lib/options.js#L95
Hi I'm using the following versions:
"tcomb-form-native": "^0.6.11",
"tcomb-json-schema": "^0.3.2"
And when I use someDate: { type: 'string', format: 'date' }
it first throws an error Missing format date, use the (format, predicate) API
.
So I added this line
transform.registerFormat('date', date => moment(date).format('dd mm'));
Now the field renders without an error, but it's type is still string. Shouldn't it be a date picker?
My apologies, it seems like you need to add a type for it to work and not a predicate.
transform.registerFormat('date', t.Date);
Hi @subodhpareek18, i have the same problem as you are, and i have followed your solution. But eventually it throws an error Error: Unrecognized date picker format undefined
. I'm also using the same version of both tcomb-form-native
and tcomb-json-schema
as you are.
Have you encounter this issue as well?
I had struggling with this issue for several days, and couldn't find a way out. And i'm also a newbie in react-native, so any help would be appreciated. Thanks.
And its only happened in Android device
@assassination I've opted for full fledged factory functions instead, where I do most of the work myself with JS. If you want can share an example.
@subodhpareek18 thats very kind of you, i think i could find a way out from your example ^^.
Could you share it to my email? rachmadnafisholeh@gmail.com
I've been working around this solution, but I still can't get it, @subodhpareek18 @nafisholeh guys I would be so thankful if you can share some examples or tips for getting work the datepicker with tcomb-form-native and tcomb-json-schema :) 👍 🤘 s@balam.rocks
Thanks!