Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Datepicker - disable validation option #3836

Closed
Blackbaud-PatrickOFriel opened this issue Jun 18, 2015 · 9 comments
Closed

Datepicker - disable validation option #3836

Blackbaud-PatrickOFriel opened this issue Jun 18, 2015 · 9 comments

Comments

@Blackbaud-PatrickOFriel
Copy link
Contributor

I have a situation where in some cases where I am using the datepicker popup and I don't want the manually entered input to go through the datepicker's validation (I want to do custom validation instead). Are there any plans to have either an option to disable validation on the datepicker or an option to provide custom validation for the datepicker (or maybe there's already a way that I'm too thick to discover today)? Thanks for all your work!

@wesleycho
Copy link
Contributor

I am currently in the process of working on a fix to the validation of the datepicker component here - once this is implemented, one can write a custom directive with a $timeout hack to overwrite ngModelCtrl.$validators, allowing for custom validators.

@wesleycho wesleycho added this to the Backlog milestone Jun 27, 2015
@wesleycho wesleycho self-assigned this Jun 27, 2015
@Blackbaud-PatrickOFriel
Copy link
Contributor Author

I found a way to hack around the current validation (albeit in a very strange way), my main pain point at the moment is this guy popping up angry and red in the console when I'm doing my own validation: $log.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');. Any way this can be a warning instead of an error?

@Blackbaud-PatrickOFriel
Copy link
Contributor Author

Any more info on whether we can have that $log.error be a warning, or better yet, not exist? I've managed to hack my own validation, but that console error keeps coming up.

@wesleycho
Copy link
Contributor

One can disable $log via

$provide.factory('$log', function() {
  return {
    debug: angular.noop,
    error: angular.noop,
    log: angular.noop,
    warn: angular.noop
  };
});

@Blackbaud-PatrickOFriel
Copy link
Contributor Author

I thought about doing that, but I really only wanted to disable the validation for this case, since I know that I'm overriding the typical validation here. I dont want to suppress all log messages in my application. I'll try to think of another way to work around it.

@wesleycho
Copy link
Contributor

One way is to file a PR that creates an injectable $datepickerSuppressError and $dateparserSuppressWarning and the $log usage in those components can then check for the truth condition. similar to how it is done in $transition.

@Blackbaud-PatrickOFriel
Copy link
Contributor Author

Okay I'll take a look at that, thanks!

@distinctdan
Copy link

I too, am in need of disabling the validation. I set the entered value to the api on the model, even if the user has entered stuff that doesn't exactly match the format, like leading 0's for the day and month. Could we add a disable-validation attribute that turns off the datepicker's validation to allow setting invalid values?

Note that I've tried ng-model-options="{ allowInvalid: true }", but it doesn't have any effect.

@mathiasdose
Copy link

It would be a great thing if this would be implemented. I for example is using using this datepicker as a filter header in ui-grid. If a user then wants to only write 2014, then the filtering won't work as 2014 is not a valid date.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants