{"size": 1608, "ext": "js", "max_stars_repo_path": "node_modules/@celo/utils/lib/inputValidation.js", "max_stars_repo_name": "fffrrreeegithub/helloCelo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/@celo/utils/lib/inputValidation.js", "max_issues_repo_name": "fffrrreeegithub/helloCelo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/@celo/utils/lib/inputValidation.js", "max_forks_repo_name": "fffrrreeegithub/helloCelo", "max_forks_repo_forks_event_min_datetime": "2022-03-09T15:44:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-11T00:09:45.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 37.3953488372, "max_line_length": 88, "alphanum_fraction": 0.6952736318}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var inputValidation_1 = require("@celo/base/lib/inputValidation");
var phoneNumbers_1 = require("./phoneNumbers");
// Exports moved to @celo/base, forwarding them
// here for backwards compatibility
var inputValidation_2 = require("@celo/base/lib/inputValidation");
exports.validateDecimal = inputValidation_2.validateDecimal;
exports.validateInteger = inputValidation_2.validateInteger;
exports.ValidatorKind = inputValidation_2.ValidatorKind;
function validatePhone(input, countryCallingCode) {
    input = input.replace(/[^0-9()\- ]/g, '');
    if (!countryCallingCode) {
        return input;
    }
    var displayNumber = phoneNumbers_1.getDisplayPhoneNumber(input, countryCallingCode);
    if (!displayNumber) {
        return input;
    }
    return displayNumber;
}
exports.validatePhone = validatePhone;
function validateInput(input, props) {
    if (!props.validator && !props.customValidator) {
        return input;
    }
    switch (props.validator) {
        case 'decimal':
            return inputValidation_1.validateDecimal(input, props.decimalSeparator);
        case 'integer':
            return inputValidation_1.validateInteger(input);
        case 'phone':
            return validatePhone(input, props.countryCallingCode);
        case 'custom': {
            if (props.customValidator) {
                return props.customValidator(input);
            }
        }
    }
    throw new Error('Unhandled input validator');
}
exports.validateInput = validateInput;
//# sourceMappingURL=inputValidation.js.map