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 10.10.10.0 for the subnet ID and 24 for 255.255.255.0 for a mask, that would be valid.  If a user input of 10.10.10.0 for the subnet ID and 16 or 255.255.0.0 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.

Thanks!

David