# Validation

Validation utility functions in TypeScript are functions that are used to validate data, ensuring that it meets specific criteria or requirements. Data validation is a crucial part of web development, as it helps ensure that user input is accurate and secure.

<details>

<summary>form.ts</summary>

```typescript
export const isEmail = (value: string): boolean => {
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  return emailRegex.test(value);
};

export const isUrl = (value: string): boolean => {
  const urlRegex =
    /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
  return urlRegex.test(value);
};

export const isPhoneNumber = (value: string): boolean => {
  const phoneRegex = /^\d{10}$/;
  return phoneRegex.test(value);
};

export const isPassword = (value: string): boolean => {
  const passwordRegex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/;
  return passwordRegex.test(value);
};

export const isRequired = (value: string): boolean => {
  return value.trim() !== "";
};

export const isNumber = (value: string | number): boolean => {
  return typeof value === "number" && !isNaN(value);
};
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tokenomy.gitbook.io/boilerplate-code/features/utilities/validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
