-
Notifications
You must be signed in to change notification settings - Fork 45
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
Datepicker always invalid #18
Comments
How I fixed it was: // Date values
if ( schema.type === 'string' && schema.format === 'date' ) {
if ( value === null ) {
value = undefined;
} else {
if ( typeof value.toISOString === 'function' ) {
value = value.toISOString();
}
}
} |
@brianpkelley Great! Thanks! I will try it! |
@brianpkelley I'm on holiday this week but I will try to add this change next week, thanks for taking the time to provide the info! :) |
In testing found a bug in the date check, I've updated my comment above to reflect the change. |
The fix above only works dates outside of arrays (i'd say average operation) if they're inside of an To fix this, I hackishly created another date format/builder with // ISO Format - 2016-08-02T17:03:18.608Z - new Date().toISOString()
var dateFormat = /^[0-9]{4,}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+|)(?:[+-][0-9]{2}:?(?:[0-9]{2}|)|Z)$/;
// Standard Format - Tue Aug 02 2016 12:03:59 GMT-0500 (CDT) - new Date().toString()
var mdDateFormat = /^(:?[A-Z][a-z]{2}\s){2}\d{1,2}\s\d{4}\s(:?\d{2}\:?){3}\s[A-Z]{3}\-\d{4}\s\([A-Z]{3}\)$/;
var formats = {
date: function (value) {
if ( value && typeof value !== 'string' && value.toISOString ) {
value = value.toISOString() || '';
}
if (dateFormat.test(value) || mdDateFormat.test(value) ) {
return null;
}
return 'A valid date expected';
}
};
tv4.addFormat( 'date', formats.date );
function dateObjectDefault(name, schema, options) {
if (schema.type === 'object' && (schema.format === 'date' || schema.format === 'date-time')) {
var f = schemaFormProvider.stdFormObj(name, schema, options);
f.key = options.path;
f.type = 'date';
options.lookup[sfPathProvider.stringify(options.path)] = f;
return f;
}
};
schemaFormProvider.defaults.object.unshift(dateObjectDefault); |
@brianpkelley hey I am facing a same problem with datepicker. After place the code above in material-decorator.js, build, and also changed the type object. I did well ? Because if a use the datepicker and chose a date seems to be fine, but if a have the field required and don't chose any date I just received "Invalid type, expected object", so do I need to change the validator.js also ? I appreciate any help. |
The datepicker is not working. When the date is selected from the datepicker the form always stays as invalid. I tried it using angular-material 1.0.7.
I also clone the repo and tried the "simple" example that fails too.
Any idea what can be happening?
Thanks
JM
The text was updated successfully, but these errors were encountered: