fCraft.RankKeyAttribute.Validate C# (CSharp) Method

Validate() public method

public Validate ( string value ) : void
value string
return void
        public override void Validate( string value )
        {
            base.Validate( value );

            Rank rank;
            if ( value.Length == 0 ) {
                rank = GetBlankValueSubstitute();
                if ( rank == null )
                    return; // ranks must not have loaded yet; can't validate
            } else {
                rank = Rank.Parse( value );
                if ( rank == null ) {
                    throw new FormatException( "Value cannot be parsed as a rank." );
                }
            }
            if ( !CanBeLowest && rank == RankManager.LowestRank ) {
                throw new FormatException( "Value may not be the lowest rank." );
            }
            if ( !CanBeHighest && rank == RankManager.HighestRank ) {
                throw new FormatException( "Value may not be the highest rank." );
            }
        }