# Required

### Make required

Checks if the given value is not `null` or `undefined`

```typescript
import Schema from "@rapidom/schema";

const Validator = Schema.number().required();
const Validator = Schema.number().required(true); // same result

// All these cases fail just because it's required
Validator.validate(); // defaults to the default value which is null by default!
Validator.validate(null);
Validator.validate(undefined);
```

### Override

Change an already required validator into a non-required one

```typescript
import Schema from "@rapidom/schema";

let Validator = Schema.number().required();

Validator = Validator.required(false); // make it not required again

// All these cases will succeed and return null
// Just because it's not required anymore
Validator.validate();
Validator.validate(null);
Validator.validate(undefined);
```


---

# 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://schema.js.org/documents/any/required.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.
