Function validate

  • Validates a value type.

    Validates a parametric value type and archives all the type errors into an IValidation.errors array, if the parametric value is not following the type T. Of course, if the parametric value is following the type T, the IValidation.errors array would be empty and IValidation.success would have the true value.

    If what you want is not finding all the error, but asserting the parametric value type with exception throwing, you can choose assert function instead. Otherwise, you just want to know whether the parametric value is matched with the type T, is function is the way to go.

    On the other and, if you don't want to allow any superfluous property that is not enrolled to the type T, you can use validateEquals function instead.

    Type Parameters

    • T

    Parameters

    • input: T

      A value to be validated

    Returns IValidation<T>

    Validation result

    Jeongho Nam - https://github.com/samchon

  • Validates a value type.

    Validates a parametric value type and archives all the type errors into an IValidation.errors array, if the parametric value is not following the type T. Of course, if the parametric value is following the type T, the IValidation.errors array would be empty and IValidation.success would have the true value.

    If what you want is not finding all the error, but asserting the parametric value type with exception throwing, you can choose assert function instead. Otherwise, you just want to know whether the parametric value is matched with the type T, is function is the way to go.

    On the other and, if you don't want to allow any superfluous property that is not enrolled to the type T, you can use validateEquals function instead.

    Type Parameters

    • T

    Parameters

    • input: unknown

      A value to be validated

    Returns IValidation<T>

    Validation result

    Jeongho Nam - https://github.com/samchon