Class CodeGeneratorPreValidator
java.lang.Object
com.broadleafcommerce.promotion.offer.service.validation.CodeGeneratorPreValidator
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.-
Constructor Summary
ConstructorDescriptionCodeGeneratorPreValidator
(CampaignService<Campaign> campaignService, CodeFormatAvailableCharHelper availableCharHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.protected CodeFormatAvailableCharHelper
protected CampaignService<Campaign>
protected int
Affects the "guessability" of codes when a code format has not been provided.void
prevalidateForCreate
(CodeGenerator codeGenerator, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Validates that the input provided by an API caller before any initialization logic is performed
-
Constructor Details
-
CodeGeneratorPreValidator
public CodeGeneratorPreValidator(CampaignService<Campaign> campaignService, CodeFormatAvailableCharHelper availableCharHelper)
-
-
Method Details
-
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
- theCodeGenerator
that is validated before createerrors
- Errors object for tracking any errorscontext
- 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:
-
getCampaignService
-
getAvailableCharHelper
-