isViewModelInstance

Source
import { isViewModelInstance } from "@prestojs/viewmodel";
isViewModelInstance<T>(object)

Check if an object is ViewModel

class User extends viewModelFactory(
  {
    id: new IntegerField(),
    name: new CharField(),
  },
  { pkFieldName: "id" }
) {}

isViewModelInstance(new User({ id: 1 }))
// true

If you need to check if a class (rather than an instance) is a ViewModel use isViewModelClass.

Params:
ParameterTypeDescription
*objectany

The object to check

Returns:boolean