> For the complete documentation index, see [llms.txt](https://schema.js.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://schema.js.org/documents/any/required.md).

# Required

Mark the value as 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);
```
