{"size": 547, "ext": "js", "max_stars_repo_path": "core.js", "max_stars_repo_name": "myx4play/node-thai-citizen-validator", "max_stars_repo_stars_event_min_datetime": "2017-07-26T02:04:30.000Z", "max_stars_repo_stars_event_max_datetime": "2017-07-26T02:04:30.000Z", "max_issues_repo_path": "core.js", "max_issues_repo_name": "myx4play/node-thai-citizen-validator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "core.js", "max_forks_repo_name": "myx4play/node-thai-citizen-validator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.88, "max_line_length": 102, "alphanum_fraction": 0.6965265082}
"use strict"

let thaiCitizenId = require('thai-citizen-generator')

let validate = (citizenId) => {
    if (validateCitizenIDPattern(citizenId)) {
        return thaiCitizenId.generateLastNumber(citizenId.substring(0, 12)) == citizenId.substring(12)
    }
    else
        return false
}

function validateCitizenIDPattern(citizenId) {
    return citizenId.match('(^\\d{13}$)')
}

Object.defineProperty(String.prototype, 'isThaiCitizenId', {
    enumerable: false,
    value: function () { return validate(this) }

})

module.exports = validate

