the definition of monomorphism as follows:

Suppose there is a very small category, which contains only two objects X and Y, where X and Y are both sets. There are only 3 morphisms in this category: idX, idY and f: X->Y. I think it should be legal to construct a category like this.
From the set point of view, the mapping f form X to Y is not necessarily an injective. But from the perspective of category, since the morphism pointing to X is only idX, then f g1 = f g2 can lead to g1=g2. Because both g1 and g2 can only be idX. In other words, f is a monomorphism.
Sorry for the very basic question. Is my understanding of the category accurate?