.*
프레임워크 연동 가이드

프레임워크별 정규표현식 검증 규칙

모든 주요 프론트엔드 및 백엔드 프레임워크에 바로 복사해 붙여넣을 수 있는 실전 유효성 검사 규칙을 제공합니다.

Node.js & TypeScript

Express-Validator & NestJS Class-Validator Regex

Validate incoming JSON payloads, route parameters, and Data Transfer Objects (DTOs) with express-validator regex and nestjs class-validator regex rules.

Express.js (express-validator)

import { body } from 'express-validator';

export const validateUser = [
  body('slug')
    .trim()
    .matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
    .withMessage('Slug must be kebab-case alphanumeric.'),
  body('postalCode')
    .matches(/^\d{5}(-\d{4})?$/)
    .withMessage('Invalid ZIP postal code.')
];

NestJS & Class-Validator

import { IsString, Matches } from 'class-validator';

export class CreateUserDto {
  @IsString()
  @Matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, {
    message: 'Invalid email address format.'
  })
  email: string;
}
PHP Frameworks

Laravel Validator & Symfony Validator Regex

Enforce strict input sanitization in PHP using laravel validator regex and symfony validator regex attributes.

Laravel FormRequest Validation

use Illuminate\Validation\Rule;

public function rules(): array
{
  return [
    'sku' => [
      'required',
      'string',
      'regex:/^[A-Z]{3}-\d{4}-[A-Z0-9]{2}$/'
    ],
  ];
}

Symfony Constraints (PHP 8 Attributes)

use Symfony\Component\Validator\Constraints as Assert;

class ProductDto
{
  #[Assert\NotBlank]
  #[Assert\Regex(
    pattern: '/^[a-z0-9-]+$/',
    message: 'Only lowercase alphanumeric and hyphens.'
  )]
  public string $slug;
}
Angular & Python

Angular FormControl & Django REST Framework Regex

Reactive UI binding via angular form control regex validator & angular email validator regex pattern, paired with django rest framework regex validator serializers.

Angular Reactive Forms

import { FormControl, Validators } from '@angular/forms';

// Phone number regex validator
const phoneRegex = /^\+?[1-9]\d{1,14}$/;
const phoneControl = new FormControl('', [
  Validators.required,
  Validators.pattern(phoneRegex)
]);

Django REST Framework Serializer

from rest_framework import serializers
from django.core.validators import RegexValidator

class AccountSerializer(serializers.Serializer):
    username = serializers.CharField(
        validators=[
            RegexValidator(
                regex=r'^[a-zA-Z0-9_]20$',
                message='Alphanumeric & underscores only.'
            )
        ]
    )
Desktop & Systems

Jira Regex Validator, Qt QLineEdit, Go & Bash

System scripting with bash regex validator, high-performance services with go validator regex, GUI masking with qlineedit regex validator, and workflow management with jira regex validator.

Qt / PyQt (QLineEdit)

// C++ Qt QRegularExpressionValidator
QRegularExpression rx("^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$");
auto *validator = new QRegularExpressionValidator(rx, this);
ui->ipAddressInput->setValidator(validator);

Go (regexp.MustCompile)

package main

import "regexp"

var emailRegex = regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`)

func IsValidEmail(email string) bool {
    return emailRegex.MatchString(email)
}

Bash Conditional Matching

#!/usr/bin/env bash

regex='^[0-9]{4}-[0-9]{2}-[0-9]{2}$'
if [[ $1 =~ $regex ]]; then
  echo "Valid ISO date: $1"
else
  echo "Invalid date format"
fi

Jira JQL & Workflow Validators

# Jira Workflow Transition Condition:
# Issue key matches release format
issue.summary.matches("^\\[PROD-[0-9]+\\].*")

# JQL text searching:
summary ~ "regex*pattern"

Framework Validation FAQ

How do I use regular expressions with express-validator?

In express-validator, chain .matches(/^regex$/) onto your field validation chain: body('username').trim().matches(/^[a-z0-9_]{3,20}$/i).withMessage('Invalid username format').

How do I validate DTO properties with nestjs class-validator?

Apply the @Matches(/pattern/, { message: '...' }) decorator from the class-validator library onto your TypeScript DTO class properties.

How does Laravel handle regex validation in FormRequests?

In Laravel, use the Rule::regex() builder or an array of rules: 'slug' => ['required', 'string', 'regex:/^[a-z0-9-]+$/']. Using an array rather than pipe syntax ('regex:/.../') is recommended to avoid delimiter parsing conflicts.

How do I validate text fields in Qt QLineEdit or PyQt?

Use QRegularExpression and QRegularExpressionValidator: QRegularExpression regex("^[A-Z0-9]+$"); QRegularExpressionValidator *validator = new QRegularExpressionValidator(regex, this); ui->lineEdit->setValidator(validator);

How do I use regex in Jira filters and issue searches?

In Jira Software, JQL supports the '~' operator for text matching and Jira Server/Data Center plugins support regex search functions like issueFunction in expressionMatches('summary', 'regex').