Set limits to transform.position

This may be really simple but I couldn’t find the answer of how to do this on the forum. This is my code to attach a GameObject to the user’s finger. In my case the object is a second camera which you can move around, magnifying the scene. Only I would like to keep the camera within smaller bounds than the entire screen. So the question is: How do I stop the movement, say, 50px from the edge of the screen?:expressionless: Thanks.

function Update () {
    for(touch in iPhoneInput.touches) {
         if(touch.phase == iPhoneTouchPhase.Moved || touch.phase == iPhoneTouchPhase.Began) {
          transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, 50));
        }
    }
}

You can use the Mathf.Clamp function to constrain a value to a particular range. Instead of basing the position directly on the value of touch.position, you should instead clamp this value to the acceptable range for the coordinate.

Thanks Andeeee
With your help I keep learning.
Worked perfectly. You da man!