How to use the vuelidate/lib/validators.helpers.regex function in vuelidate

To help you get started, we’ve selected a few vuelidate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / vuelidate / vuelidate-tests.ts View on Github external
const mustBeCool: CustomRule = (value: string) => value.indexOf('cool') >= 0

const mustBeCool2: CustomRule = (value: string) => !helpers.req(value) || value.indexOf('cool') >= 0

const contains = (param: string): CustomRule =>
    (value: string) => !helpers.req(value) || value.indexOf(param) >= 0

const mustBeCool3 = helpers.withParams(
    { type: 'mustBeCool3' },
    (value: any) => !helpers.req(value) || value.indexOf('cool') >= 0
)

const mustBeCool3Result: boolean = mustBeCool3(50)

const mustBeCool4 = helpers.regex('mustBeCool4', /^.*cool.*$/)

const mustBeSame = (reference: string) => helpers.withParams(
    { type: 'mustBeSame' },
    (value: any, parentVm?: Vue) =>
        value === helpers.ref(reference, self, parentVm)
)

const mustHaveLength = (minLen: number) => helpers.withParams(
    { type: 'mustHaveLength' },
    (value: any) =>
        helpers.len(value) > minLen
)

@Component({
    validations: {
        password: {
github jhipster / jhipster-vuejs / generators / client / templates / vue / src / main / webapp / app / components / account / register / Register.component.ts View on Github external
import RegisterService from '../RegisterService.vue';
import LoginModalService from '../LoginModalService.vue';
import TranslationService from '../../../locale/TranslationService.vue';
import { required, minLength, maxLength, helpers, email } from 'vuelidate/lib/validators';
import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../../../constants';

const loginPattern = helpers.regex('alpha', /^[_.@A-Za-z0-9-]*$/);

const Register = {
  name: 'Register',
  mixins: [RegisterService, LoginModalService, TranslationService],
  data() {
    return {
      confirmPassword: undefined,
      doNotMatch: undefined,
      error: undefined,
      errorEmailExists: undefined,
      errorUserExists: undefined,
      registerAccount: {
        login: undefined,
        email: undefined,
        password: undefined
      },