Sha256: 58c78fc76d5792d10c5242552914178a3112e151de349c4fd55db7be53ae6ef8

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

import extend from '../utils/extend';
import { createUTC } from './utc';
import getParsingFlags from '../create/parsing-flags';
import some from '../utils/some';

export function isValid(m) {
    if (m._isValid == null) {
        var flags = getParsingFlags(m);
        var parsedParts = some.call(flags.parsedDateParts, function (i) {
            return i != null;
        });
        var isNowValid = !isNaN(m._d.getTime()) &&
            flags.overflow < 0 &&
            !flags.empty &&
            !flags.invalidMonth &&
            !flags.invalidWeekday &&
            !flags.nullInput &&
            !flags.invalidFormat &&
            !flags.userInvalidated &&
            (!flags.meridiem || (flags.meridiem && parsedParts));

        if (m._strict) {
            isNowValid = isNowValid &&
                flags.charsLeftOver === 0 &&
                flags.unusedTokens.length === 0 &&
                flags.bigHour === undefined;
        }

        if (Object.isFrozen == null || !Object.isFrozen(m)) {
            m._isValid = isNowValid;
        }
        else {
            return isNowValid;
        }
    }
    return m._isValid;
}

export function createInvalid (flags) {
    var m = createUTC(NaN);
    if (flags != null) {
        extend(getParsingFlags(m), flags);
    }
    else {
        getParsingFlags(m).userInvalidated = true;
    }

    return m;
}

Version data entries

7 entries across 7 versions & 5 rubygems

Version Path
cortex-0.1.3 spec/dummy/node_modules/moment/src/lib/create/valid.js
jinda_lte-0.0.1 lib/generators/jinda_lte/templates/app/assets/jinda_assets/bower_components/moment/src/lib/create/valid.js
binnacle-0.5.0 vendor/assets/javascripts/moment/src/lib/create/valid.js
binnacle-0.4.9 vendor/assets/javascripts/moment/src/lib/create/valid.js
binnacle-0.4.8 vendor/assets/javascripts/moment/src/lib/create/valid.js
lanes-0.8.0 node_modules/moment/src/lib/create/valid.js
date_picker-0.0.9 test/dummy/vendor/assets/components/moment/src/lib/create/valid.js