Skip to main content

Image

Check if the input value is a file and the file type is an image.

The validation rule requires a value to run.

Example

src/app/posts/controllers/create-post.ts
// ...
createPost.validation = {
rules: {
title: ["required"],
image: ["required", "image"],
},
};

It works also if the input is an array of images:

src/app/posts/controllers/create-post.ts
// ...
createPost.validation = {
rules: {
title: ["required"],
images: ["required", "image"],
},
};