Closed tedeschia closed 8 months ago
@tedeschia here is how i would do it: https://github.com/tedeschia/yup/compare/2043-performance-improvement...jquense%3Ayup%3A2043-performance-improvement
@jquense great! I have adopted your proposal, made a minor fix (setting "type" prop on ValidationError constructor), updated the project using the consolidated ValidationError class and fixing some tests. Are we OK to merge the changes now?
thanks!
This Pull Request introduces
ValidationErrorNoStack
, a class aimed at enhancing performance in error validation processes. Similar toValidationError
, it does not extend fromError
and avoids capturing the stack trace. This approach significantly improves efficiency, particularly for validations of large arrays.Key Features:
ValidationErrorNoStack
Class: Implements theValidationError
interface, but without stack trace capturing.disableStackTrace = false
: RetainsValidationError
, standard behavior including stack trace.disableStackTrace = true
: Switches toValidationErrorNoStack
, optimizing performance by skipping stack trace capture.Benefits:
disableStackTrace = false
ensures existing functionality is unaffected.This update provides an efficient solution for intensive validation scenarios while preserving the functionality for current users.