CustomCodes‎ > ‎

Custom validation formula in columns

//To get 4 digit number in a field 'Year' of single line text type:

=
IF(LEN(Year)=4,ISNUMBER(Year+0),FALSE)

More references: 
Restrict data input by using validation rules