https://github.com/maciejkuran/forms-validation-api
Introducing the Lightning Fast Free Form Validation REST API! 🚀 This API effortlessly takes care of all your validation needs! 🎁
https://github.com/maciejkuran/forms-validation-api
email-validation form-validation forms password-validation rest-api restful-api validation-api
Last synced: 3 months ago
JSON representation
Introducing the Lightning Fast Free Form Validation REST API! 🚀 This API effortlessly takes care of all your validation needs! 🎁
- Host: GitHub
- URL: https://github.com/maciejkuran/forms-validation-api
- Owner: maciejkuran
- Created: 2023-07-16T13:30:44.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-21T15:38:06.000Z (almost 2 years ago)
- Last Synced: 2025-01-12T00:21:29.740Z (4 months ago)
- Topics: email-validation, form-validation, forms, password-validation, rest-api, restful-api, validation-api
- Language: TypeScript
- Homepage: https://forms-validation-api.vercel.app/
- Size: 190 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Forms Validation API ⚡
![]()
You don't have to worry about form validation anymore, and write boilerplate code 😩. This API handles validation out-of-the-box 📦! It's as simple as that.
---
**Current version: 1.0**
🔗 API Base URL: `https://forms-validation-api.vercel.app/api/v1.0`
[🔗 Documentation](https://forms-validation-api.vercel.app)
---
## API Endpoints
There are 4 endpoints to choose from.
You can expect a response with a status code of `400` (if validation failed), and `200` if succeded. More in the examples section.| Description | Method | Expected req.body | Endpoint |
| ---------------------- | ------ | ------------------------------------------------------------ | ----------- |
| Validate password | `POST` | `{password: $value}` | `/password` |
| Validate email address | `POST` | `{email: $value}` | `/email` |
| Sign In Form | `POST` | `{email: $value, password: $value}` | `/sign-in` |
| Sign Up Form | `POST` | `{email: $value, password: $value, confirmPassword: $value}` | `/sign-up` |### Validating Only Password 🔑
👉 Endpoint: `/password`
We check whether the password:
- is not empty,
- contains at least 8 characters,
- contains at least 1 digit,
- contains at least 1 capital letter,
- contains at least 1 special character.### Validating Only Email Address 📧
👉 Endpoint: `/email`
We check whether the email address:
- is not empty,
- doesn't contain special characters such as `!#$%^&\*(),?\":{}|<>~^+/=`,
- has no spaces,
- contains the `@` symbol,
- does not have an additional `@` in the username portion,
- does not contain offensive, vulgar, or inappropriate content (example words will not be mentioned here for ethical reasons).### Sign In Form Validation
👉 Endpoint: `/sign-in`
- validating both: email & password.
### Sign Up Form Validation
👉 Endpoint: `/sign-up`
- validating: email, password & password match.
## Example
In the example provided below, I am validating the user's password. The same analogy applies to each available form of validation.
```
const url = 'https://form-validation-api.vercel.app/api';const reqConfig = (method: string, body: {}): {} => {
return {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
},
};
};const validatePassword = async (password: string) => {
try {
const res = await fetch(`${url}/password`, reqConfig('POST', { password }));
const validationResult = await res.json();if (!res.ok) throw new Error(validationResult.error); // if 400 code, 'error' key is available on the response object
//If we got here, it means that validation is successful
console.log(validationResult.success); //if 200 code, 'success' key is available on the res. object
} catch (error) {
console.log((error as Error).message);
}
};```
## Rate Limit Middleware
Rate limiting is a strategy employed to restrict network traffic and prevent potential abuse of APIs. Each API route is equipped with its own `rateLimiter` variable, which records the `timestamps` of user requests. That, in essence, summarizes the concept.
The number of permitted requests per user, per minute for each API route is set at `10`.
## Contribution
Hey there, awesome folks! 👋 I am on a mission to make magic happen, and I may need your collaboration superpowers! Let's team up, share ideas, and pool our talents to create something useful 🚀💫. Feel free to `fork` repo and `pull requests` or submit your request via `issues`.
#CollaborationNation