leafjs/orient

View on GitHub
src/types/integer.js

Summary

Maintainability
A
0 mins
Test Coverage
import Type from './type';
import _ from 'lodash';

export default class IntegerType extends Type {
    _serialize(value) {
        var val = parseInt(value);
        if(_.isNaN(value)) {
            throw new Error('Value is NaN');
        }

        return val;
    }

    _deserialize(value) {
        return value;
    }

    static toString() {
        return 'Integer';
    }    

    static getDbType(options) {
        return 'INTEGER';
    }
}