[common] generalize valueRange check