Class CodeGeneratorPreValidator


  • public class CodeGeneratorPreValidator
    extends Object
    Validation ran on a CodeGenerator before create. This is a separate validation from CodeGeneratorValidator which is an entity validator that runs at a later phase. This component is specifically used in DefaultCodeGeneratorService to test the input provided by an API caller before any initialization logic kicks in.
    • Method Detail

      • prevalidateForCreate

        public void prevalidateForCreate​(@NonNull
                                         CodeGenerator codeGenerator,
                                         org.springframework.validation.Errors errors,
                                         @Nullable
                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Validates that the input provided by an API caller before any initialization logic is performed
        Parameters:
        codeGenerator - the CodeGenerator that is validated before create
        errors - Errors object for tracking any errors
        context - context surrounding sandboxing and multitenant state
      • calculateRequiredCodeLength

        protected int calculateRequiredCodeLength​(int numberOfCodes,
                                                  int charSetSize)
        Returns the size of the code that you must create in order to support the passed in number of Codes.
        Parameters:
        numberOfCodes -
        Returns:
      • getCodeMultiplier

        protected int getCodeMultiplier()
        Affects the "guessability" of codes when a code format has not been provided. For example, if 100 codes are being generated, the default will insure that the codes are generated at least from a pool of 100000 possible codes.
        Returns: