MCPcopy Create free account
hub / github.com/ampproject/amphtml / isValid

Function isValid

third_party/inputmask/inputmask.js:1293–1407  ·  view source on GitHub ↗
(pos, c, strict, fromSetValid, fromAlternate, validateOnly)

Source from the content-addressed store, hash-verified

1291 return isValidRslt;
1292 }
1293 function isValid(pos, c, strict, fromSetValid, fromAlternate, validateOnly) {
1294 function isSelection(posObj) {
1295 return isRTL ? posObj.begin - posObj.end > 1 || posObj.begin - posObj.end === 1 : posObj.end - posObj.begin > 1 || posObj.end - posObj.begin === 1;
1296 }
1297 strict = strict === true;
1298 var maskPos = pos;
1299 if (pos.begin !== undefined) {
1300 maskPos = isRTL ? pos.end : pos.begin;
1301 }
1302 function _isValid(position, c, strict) {
1303 var rslt = false;
1304 $.each(getTests(position), function(ndx, tst) {
1305 var test = tst.match;
1306 getBuffer(true);
1307 rslt = test.fn != null ? test.fn.test(c, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? {
1308 c: getPlaceholder(position, test, true) || test.def,
1309 pos: position
1310 } : false;
1311 if (rslt !== false) {
1312 var elem = rslt.c !== undefined ? rslt.c : c, validatedPos = position;
1313 elem = elem === opts.skipOptionalPartCharacter && test.fn === null ? getPlaceholder(position, test, true) || test.def : elem;
1314 if (rslt.remove !== undefined) {
1315 if (!$.isArray(rslt.remove)) rslt.remove = [ rslt.remove ];
1316 $.each(rslt.remove.sort(function(a, b) {
1317 return b - a;
1318 }), function(ndx, lmnt) {
1319 revalidateMask({
1320 begin: lmnt,
1321 end: lmnt + 1
1322 });
1323 });
1324 }
1325 if (rslt.insert !== undefined) {
1326 if (!$.isArray(rslt.insert)) rslt.insert = [ rslt.insert ];
1327 $.each(rslt.insert.sort(function(a, b) {
1328 return a - b;
1329 }), function(ndx, lmnt) {
1330 isValid(lmnt.pos, lmnt.c, true, fromSetValid);
1331 });
1332 }
1333 if (rslt !== true && rslt.pos !== undefined && rslt.pos !== position) {
1334 validatedPos = rslt.pos;
1335 }
1336 if (rslt !== true && rslt.pos === undefined && rslt.c === undefined) {
1337 return false;
1338 }
1339 if (!revalidateMask(pos, $.extend({}, tst, {
1340 input: casing(elem, test, validatedPos)
1341 }), fromSetValid, validatedPos)) {
1342 rslt = false;
1343 }
1344 return false;
1345 }
1346 });
1347 return rslt;
1348 }
1349 var result = true, positionsClone = $.extend(true, {}, getMaskSet().validPositions);
1350 if ($.isFunction(opts.preValidation) && !strict && fromSetValid !== true && validateOnly !== true) {

Callers 11

parseDateFunction · 0.85
DateRangePickerWithRefFunction · 0.85
getDateType_Method · 0.85
SingleDatePickerWithRefFunction · 0.85
refreshFromBufferFunction · 0.85
alternateFunction · 0.85
_isValidFunction · 0.85
trackbackPositionsFunction · 0.85
revalidateMaskFunction · 0.85
maskScopeFunction · 0.85
checkValFunction · 0.85

Calls 11

getMaskSetFunction · 0.85
getBufferFunction · 0.85
isSelectionFunction · 0.85
trackbackPositionsFunction · 0.85
_isValidFunction · 0.85
seekNextFunction · 0.85
isMaskFunction · 0.85
isCompleteFunction · 0.85
alternateFunction · 0.85
refreshFromBufferFunction · 0.85
resetMaskSetFunction · 0.85

Tested by

no test coverage detected