This REST API was built in Go using the Chi framework. This is a simple microservice that provides a RESTful API endpoint that can validate passwords based on a set of predefined rules.
- RESTful API endpoint for password validation (
/v1/users/password-validation
). - Modular rule-based validation system.
- Easy to extend and create new rules for validation.
The application provides validators for the following rules:
Request:
POST /v1/users/validate-password
Content-Type: application/json
{
"password": "YourPwd123!"
}
cURL:
curl --location 'http://localhost:8080/v1/users/validate-password' \
--header 'Content-Type: application/json' \
--data '{
"password": "YourPwd123!"
}'
Response:
{
"valid": true,
"errors": []
}
Request:
POST /v1/users/validate-password
Content-Type: application/json
{
"password": "YourPassword123!"
}
cURL:
curl --location 'http://localhost:8080/v1/users/validate-password' \
--header 'Content-Type: application/json' \
--data '{
"password": "YourPassword123!"
}'
Response:
{
"valid": false,
"errors": [
"must not contain repeated characters"
]
}
- Go 1.23.0 or higher
- (optional) Docker
To install the application, follow these steps:
- Clone the repository
git clone https://github.om/vitorvasc/password-validator-api.git
- Run the application
go run cmd/api/main/main.go
The server will start on port 8080 by default.
- Run the tests:
go test -v ./...
- Run the tests with coverage:
go test -v ./... -cover
Feel free to submit issues, fork the repository and create pull requests for any improvements.