old-value.js 463 B

12345678910111213141516171819202122
  1. let utils = require('./utils')
  2. class OldValue {
  3. constructor(unprefixed, prefixed, string, regexp) {
  4. this.unprefixed = unprefixed
  5. this.prefixed = prefixed
  6. this.string = string || prefixed
  7. this.regexp = regexp || utils.regexp(prefixed)
  8. }
  9. /**
  10. * Check, that value contain old value
  11. */
  12. check(value) {
  13. if (value.includes(this.string)) {
  14. return !!value.match(this.regexp)
  15. }
  16. return false
  17. }
  18. }
  19. module.exports = OldValue