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

Function _isValid

third_party/inputmask/inputmask.js:1302–1348  ·  view source on GitHub ↗
(position, c, strict)

Source from the content-addressed store, hash-verified

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) {
1351 result = opts.preValidation(getBuffer(), maskPos, c, isSelection(pos), opts, getMaskSet());

Callers 1

isValidFunction · 0.85

Calls 9

getTestsFunction · 0.85
getBufferFunction · 0.85
getMaskSetFunction · 0.85
isSelectionFunction · 0.85
getPlaceholderFunction · 0.85
revalidateMaskFunction · 0.85
isValidFunction · 0.85
casingFunction · 0.85
testMethod · 0.45

Tested by

no test coverage detected