better regex for durations

This commit is contained in:
Tarek Rached 2015-02-06 17:02:31 -08:00
parent 1ee4f7cc13
commit a0fc20fc09
1 changed files with 12 additions and 12 deletions

View File

@ -11829,7 +11829,7 @@ app.directive('isoDuration', function() {
require: 'ngModel',
link: function($scope, $el, $attrs, $ctrl) {
var durationRegex;
durationRegex = /^P(((\d+)Y)?((\d)+M)?((\d)+D)?|(\d)+W)$/;
durationRegex = /^P(?=\w*\d)(?:\d+Y|Y)?(?:\d+M|M)?(?:\d+W|W)?(?:\d+D|D)?(?:T(?:\d+H|H)?(?:\d+M|M)?(?:\d+(?:\­.\d{1,2})?S|S)?)?$/;
return $ctrl.$parsers.unshift(function(viewValue) {
if (viewValue == null) {
$ctrl.$setValidity('isoDuration', true);