Subnet ID validation

Has anybody built a task that would validate a given subnet ID to a given subnet mask?  For example, if a user input was for the subnet ID and 24 for for a mask, that would be valid.  If a user input of for the subnet ID and 16 or would be invalid.  I thought I had seen a subnet validation operation in base content before, but I cannot seem to find it now.  Just trying not to recreate the wheel here.