Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 22, 2025

This PR updates the username validation in UsuarioType.php to allow hyphens (-) and underscores (_) in addition to the currently supported letters, numbers, and periods.

Changes Made

Updated the regex pattern from:

new Regex("/^[a-zA-Z0-9\.]+$/")

To:

new Regex("/^[a-zA-Z0-9\.\-_]+$/")

Also updated the corresponding JavaScript input filter from:

"this.value = this.value.replace(/([^\w\d\.])+/g, '')"

To:

"this.value = this.value.replace(/([^\w\d\.\-_])+/g, '')"

Supported Username Patterns

The following username patterns are now supported:

  • username (letters and numbers)
  • user.name (with periods)
  • user-name (with hyphens) ✨ NEW
  • user_name (with underscores) ✨ NEW

Validation

Both server-side (PHP) and client-side (JavaScript) validation have been updated to maintain consistency. Invalid characters like spaces, @, #, etc. are still properly rejected.

Fixes #4.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/doctrine/collections/zipball/2eb07e5953eed811ce1b309a7478a3b236f2273d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/pNjXCG /usr/bin/composer install (http block)
  • https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/XwV18c /usr/bin/composer install --no-dev (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: rogeriolino <1065082+rogeriolino@users.noreply.github.com>
Copilot AI changed the title [WIP] Username validation Update username validation to support hyphens and underscores Jul 22, 2025
Copilot AI requested a review from rogeriolino July 22, 2025 21:47
@rogeriolino
Copy link
Member

@copilot create a unit test using PHPUnit inside the "tests" folder. This new testcase must extend the TypeTestCase (Symfony\Component\Form\Test\TypeTestCase) class.

Co-authored-by: rogeriolino <1065082+rogeriolino@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 22, 2025

@copilot create a unit test using PHPUnit inside the "tests" folder. This new testcase must extend the TypeTestCase (Symfony\Component\Form\Test\TypeTestCase) class.

I've created a comprehensive PHPUnit test class UsuarioTypeTest that extends TypeTestCase as requested. The test includes:

  • Username validation testing with data providers covering all valid patterns (letters, numbers, periods, hyphens, underscores)
  • Invalid character rejection tests
  • Length constraint validation (min 3, max 30)
  • Required field validation
  • Email validation
  • Admin field conditional presence
  • Password vs. active field logic for new vs. existing users

The test validates that the updated regex pattern /^[a-zA-Z0-9\.\-_]+$/ correctly accepts usernames with hyphens and underscores while rejecting invalid characters.

Commit: 9bdfc32

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/BabDev/Pagerfanta/zipball/b09216fc53665c4d8a39b7f60e421165cb4693e4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/doctrine/collections/zipball/2eb07e5953eed811ce1b309a7478a3b236f2273d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/b42cLe /usr/bin/composer install --no-dev --ignore-platform-reqs (http block)
  • https://api.github.com/repos/doctrine/dbal/zipball/ac336c95ea9e13433d56ca81c308b39db0e1a2a7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/b42cLe /usr/bin/composer install --no-dev --ignore-platform-reqs (http block)
  • https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/b42cLe /usr/bin/composer install --no-dev --ignore-platform-reqs (http block)
  • https://api.github.com/repos/doctrine/lexer/zipball/31ad66abc0fc9e1a1f2d9bc6a42668d2fbbcd6dd
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/doctrine/orm/zipball/6deec3655ba3e8f15280aac11e264225854d2369
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/novosga/core/zipball/4b00d86fc9acb6528d7e2bbf420b751732c00bf6
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/fcf8b71aeab4e1a1131d1783cef97b23a51b87a9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/console/zipball/9e27aecde8f506ba0fd1d9989620c04a87697101
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/error-handler/zipball/35b55b166f6752d6aaf21aa042fc5ed280fce235
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/event-dispatcher/zipball/497f73ac996a598c92409b44ac43b6690c4f666d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/form/zipball/7a48dda96fe16711fc042df38ca1a7dd4d9d6387
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/http-foundation/zipball/23dd60256610c86a3414575b70c596e5deff6ed9
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/http-kernel/zipball/576eb3368037dd139f67b8ac71db56c3f69f7d66
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/options-resolver/zipball/afb9a8038025e5dbc657378bfab9198d75f10fca
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/password-hasher/zipball/2e618d1af51805e5a1fbda326d00b77c6c1037d5
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/763d2a91fea5681509ca01acbc1c5e450d127811
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php84/zipball/000df7860439609837bbe28670b0be15783b7fbf
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/b42cLe /usr/bin/composer install --no-dev --ignore-platform-reqs (http block)
  • https://api.github.com/repos/symfony/property-access/zipball/518d15c8cca726ebe665dcd7154074584cf862e8
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/property-info/zipball/90586acbf2a6dd13bee4f09f09111c8bd4773970
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/security-core/zipball/0931c6bb15b696e1a4da8405c255b3a8673dcb3c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/string/zipball/f3570b8c61ca887a9e2938e85cb6458515d2b125
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/type-info/zipball/5fa6e25e4195e73ce9e457b521ac5e61ec271150
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/validator/zipball/bb226e43829a6554cf891bd7c176dc73d49bc6c1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/var-dumper/zipball/6e209fbe5f5a7b6043baba46fe5735a4b85d0d42
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/var-exporter/zipball/c9a1168891b5aaadfd6332ef44393330b3498c4c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/Sv9SOI /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@rogeriolino rogeriolino marked this pull request as ready for review July 23, 2025 12:51
Copy link
Member

@rogeriolino rogeriolino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build failing due to phpcs (command vendor/bin/phpcs) errors:

FILE: tests/Form/UsuarioTypeTest.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------
  1[9](https://github.com/novosga/users-bundle/actions/runs/16456559555/job/46560392634?pr=5#step:5:10) | ERROR | [x] Type Symfony\Component\Form\FormInterface is not used in
     |       |     this file.
 136 | ERROR | [x] Whitespace found at end of line
 202 | ERROR | [x] Whitespace found at end of line
 205 | ERROR | [x] Expected 1 newline at end of file; 0 found

Co-authored-by: rogeriolino <1065082+rogeriolino@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 23, 2025

build failing due to phpcs (command vendor/bin/phpcs) errors:

...

Fixed all PHPCS errors: removed unused FormInterface import, removed trailing whitespace, and added missing newline at end of file. Commit: e41a4e7

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/yiA7RQ /usr/bin/composer install --ignore-platform-reqs (http block)
  • https://api.github.com/repos/doctrine/collections/zipball/2eb07e5953eed811ce1b309a7478a3b236f2273d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/HFG5ay /usr/bin/composer install --no-dev --ignore-platform-reqs (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/yiA7RQ /usr/bin/composer install --ignore-platform-reqs (http block)
  • https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/HFG5ay /usr/bin/composer install --no-dev --ignore-platform-reqs (http block)
  • https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/yiA7RQ /usr/bin/composer install --ignore-platform-reqs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from rogeriolino July 23, 2025 13:12
…ethod calls

Co-authored-by: rogeriolino <1065082+rogeriolino@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 23, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/kQh61N /usr/bin/composer install --ignore-platform-reqs (http block)
  • https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/kQh61N /usr/bin/composer install --ignore-platform-reqs (http block)
  • https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/kQh61N /usr/bin/composer install --ignore-platform-reqs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from rogeriolino July 23, 2025 13:37
@rogeriolino rogeriolino merged commit 57d294b into v2.2 Jul 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Username validation

2 participants