import Formatter from 'field-kit/src/formatter';

// A formatter that only allows numbers. This is good for numbers meant ot be
// strings, such as zip code, account numbers. Set this.maximumLength to limit
// the amount of digits allowed.
class DigitsFormatter extends Formatter {
    isChangeValid(change, error) {
        if (/^\d*$/.test(change.inserted.text)) {
            return super.isChangeValid(change, error);
        } else {
            return false;
        }
    }
}

export default DigitsFormatter;
