{"size": 845, "ext": "js", "max_stars_repo_path": "src/models/fields/number.field.js", "max_stars_repo_name": "ceddl/ceddl-polyfill", "max_stars_repo_stars_event_min_datetime": "2019-01-01T10:50:00.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T23:53:17.000Z", "max_issues_repo_path": "src/models/fields/number.field.js", "max_issues_repo_name": "ceddl/ceddl-polyfill", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/models/fields/number.field.js", "max_forks_repo_name": "ceddl/ceddl-polyfill", "max_forks_repo_forks_event_min_datetime": "2021-12-03T14:18:31.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-03T14:18:31.000Z"}
{"max_stars_count": 12, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 24.8529411765, "max_line_length": 74, "alphanum_fraction": 0.6674556213}
import { Field } from './field.js';

/**
 * Create a NumberField on a model to validate a number value
 * Creates an instance of NumberField.
 * @param {string} key The field's key for sending to analytics
 * @param {number} value The field's value
 * @param {boolean} required Is the field required?
 * @memberof NumberField
 */
function NumberField(key, value, required) {
    Field.call(this, key, value, required);
    if (value) {
        this.value = parseFloat(value);

        if (isNaN(this.value)) {
            this.error = 'Invalid value for NumberField '+ key +':'+value;
        }
    }
}

NumberField.isFlat = function() {
    return true;
};

NumberField.isList = function() {
    return false;
};

NumberField.prototype = Object.create(Field.prototype);
NumberField.prototype.constructor = NumberField;

export { NumberField };
