summaryrefslogtreecommitdiff
path: root/src/components/_sila/Mixins/VuelidateMixin.js
blob: 343d24a7b9eead3c2b8042dc5e6f2277be3fc074 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const VuelidateMixin = {
  methods: {
    getValidationState(model) {
      const { $dirty, $error } = model;
      return $dirty ? !$error : null;
    },
    getIpValidationState(model) {
      const { $dirty, $error, $model } = model;
      return $dirty
        ? !$error &&
            /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(
              $model
            )
        : null;
    },
  },
};

export default VuelidateMixin;