UniVocity howto add parameters to a custom ValidatorValidate decimal numbers in JavaScript - IsNumeric()How to validate an email address in JavaScriptA comprehensive regex for phone number validation(Built-in) way in JavaScript to check if a string is a valid numberHow to validate an email address using a regular expression?What is the maximum length of a valid email address?Does Java support default parameter values?Sort ArrayList of custom Objects by propertyjpa2 db reverse engineering with bean validation annotationsBean Validation message interpolation with array constraint parameter used as variable in message

Does wetting a beer glass change the foam characteristics?

Is there any relation/leak between two sections of LM358 op-amp?

Is it more effective to add yeast before or after kneading?

Designing a time thief proof safe

Hilbert's hotel: why can't I repeat it infinitely many times?

Is it possible to encode a message in such a way that can only be read by someone or something capable of seeing into the very near future?

How to say "cheat sheet" in French

On the meaning of 'anyways' in "What Exactly Is a Quartz Crystal, Anyways?"

Word or Phrase Meaning False Self-Criticism

Under what circumstances would RAM locations 0 and 1 be written and/or read on the C64?

Why did the Soviet Union not "grant" Inner Mongolia to Mongolia after World War Two?

Lost Update Understanding

Symbol for function composition like a big sum

What are the consequences of high orphan block rate?

Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?

How to clarify between imagined sensations and "real" fantasy events?

Clear text passwords in Unix

Do we know the situation in Britain before Sealion (summer 1940)?

Pi Zero Work With Embedded WIFI And Cellular USB Modem

What secular civic space would pioneers build for small frontier towns?

List of 1000 most common words across all languages

How can this Stack Exchange site have an animated favicon?

Carry vs Roll-Down on a zero-coupon IRS

What is the white pattern on trim wheel for?



UniVocity howto add parameters to a custom Validator


Validate decimal numbers in JavaScript - IsNumeric()How to validate an email address in JavaScriptA comprehensive regex for phone number validation(Built-in) way in JavaScript to check if a string is a valid numberHow to validate an email address using a regular expression?What is the maximum length of a valid email address?Does Java support default parameter values?Sort ArrayList of custom Objects by propertyjpa2 db reverse engineering with bean validation annotationsBean Validation message interpolation with array constraint parameter used as variable in message






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I'm creating some custom Validators for univocity parser and I want to add some parameters like this:



 public class Size implements Validator<String>
int max;


and then use it like this:



 @Parsed
@Validate(nullable = false, validators = Size.class(8) )
private String someString;


I didn't found anything like this or examples with annotations.



Maybe using javax.validation annotations?



Or maybe injecting sizeValidation object created with range limit constructor?



Thanks!










share|improve this question
























  • Partially solved. Size could be validated with RegEx ^_^ matches = "^.3,5$" size min=3, max=5

    – Jesús David López
    Mar 29 at 9:29


















2















I'm creating some custom Validators for univocity parser and I want to add some parameters like this:



 public class Size implements Validator<String>
int max;


and then use it like this:



 @Parsed
@Validate(nullable = false, validators = Size.class(8) )
private String someString;


I didn't found anything like this or examples with annotations.



Maybe using javax.validation annotations?



Or maybe injecting sizeValidation object created with range limit constructor?



Thanks!










share|improve this question
























  • Partially solved. Size could be validated with RegEx ^_^ matches = "^.3,5$" size min=3, max=5

    – Jesús David López
    Mar 29 at 9:29














2












2








2


1






I'm creating some custom Validators for univocity parser and I want to add some parameters like this:



 public class Size implements Validator<String>
int max;


and then use it like this:



 @Parsed
@Validate(nullable = false, validators = Size.class(8) )
private String someString;


I didn't found anything like this or examples with annotations.



Maybe using javax.validation annotations?



Or maybe injecting sizeValidation object created with range limit constructor?



Thanks!










share|improve this question














I'm creating some custom Validators for univocity parser and I want to add some parameters like this:



 public class Size implements Validator<String>
int max;


and then use it like this:



 @Parsed
@Validate(nullable = false, validators = Size.class(8) )
private String someString;


I didn't found anything like this or examples with annotations.



Maybe using javax.validation annotations?



Or maybe injecting sizeValidation object created with range limit constructor?



Thanks!







java validation univocity






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 17:38









Jesús David LópezJesús David López

132 bronze badges




132 bronze badges















  • Partially solved. Size could be validated with RegEx ^_^ matches = "^.3,5$" size min=3, max=5

    – Jesús David López
    Mar 29 at 9:29


















  • Partially solved. Size could be validated with RegEx ^_^ matches = "^.3,5$" size min=3, max=5

    – Jesús David López
    Mar 29 at 9:29

















Partially solved. Size could be validated with RegEx ^_^ matches = "^.3,5$" size min=3, max=5

– Jesús David López
Mar 29 at 9:29






Partially solved. Size could be validated with RegEx ^_^ matches = "^.3,5$" size min=3, max=5

– Jesús David López
Mar 29 at 9:29













1 Answer
1






active

oldest

votes


















1
















Two options here:



1 - add the annotations on a setter (simple but not reusable:



 @Parsed
@Validate(nullable = false)
public void setSomeString(String value)


2 - extend class ValidatedConversion and use that class on a @Convert annotation:



public class LengthValidator extends ValidatedConversion 

private int min;
private int max;

public LengthValidator(String... args)
super(false, false); //not null / not blank
this.min = Integer.parseInt(args[0]);
this.max = Integer.parseInt(args[1]);


@Override
protected void validate(Object value)



Then add it to your attribute:



 @Parsed
@Convert(conversionClass = LengthValidator.class, args = "3", "5")
private String someString;


Hope this helps.






share|improve this answer

























  • It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

    – Jesús David López
    Apr 4 at 10:32













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403794%2funivocity-howto-add-parameters-to-a-custom-validator%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1
















Two options here:



1 - add the annotations on a setter (simple but not reusable:



 @Parsed
@Validate(nullable = false)
public void setSomeString(String value)


2 - extend class ValidatedConversion and use that class on a @Convert annotation:



public class LengthValidator extends ValidatedConversion 

private int min;
private int max;

public LengthValidator(String... args)
super(false, false); //not null / not blank
this.min = Integer.parseInt(args[0]);
this.max = Integer.parseInt(args[1]);


@Override
protected void validate(Object value)



Then add it to your attribute:



 @Parsed
@Convert(conversionClass = LengthValidator.class, args = "3", "5")
private String someString;


Hope this helps.






share|improve this answer

























  • It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

    – Jesús David López
    Apr 4 at 10:32















1
















Two options here:



1 - add the annotations on a setter (simple but not reusable:



 @Parsed
@Validate(nullable = false)
public void setSomeString(String value)


2 - extend class ValidatedConversion and use that class on a @Convert annotation:



public class LengthValidator extends ValidatedConversion 

private int min;
private int max;

public LengthValidator(String... args)
super(false, false); //not null / not blank
this.min = Integer.parseInt(args[0]);
this.max = Integer.parseInt(args[1]);


@Override
protected void validate(Object value)



Then add it to your attribute:



 @Parsed
@Convert(conversionClass = LengthValidator.class, args = "3", "5")
private String someString;


Hope this helps.






share|improve this answer

























  • It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

    – Jesús David López
    Apr 4 at 10:32













1














1










1









Two options here:



1 - add the annotations on a setter (simple but not reusable:



 @Parsed
@Validate(nullable = false)
public void setSomeString(String value)


2 - extend class ValidatedConversion and use that class on a @Convert annotation:



public class LengthValidator extends ValidatedConversion 

private int min;
private int max;

public LengthValidator(String... args)
super(false, false); //not null / not blank
this.min = Integer.parseInt(args[0]);
this.max = Integer.parseInt(args[1]);


@Override
protected void validate(Object value)



Then add it to your attribute:



 @Parsed
@Convert(conversionClass = LengthValidator.class, args = "3", "5")
private String someString;


Hope this helps.






share|improve this answer













Two options here:



1 - add the annotations on a setter (simple but not reusable:



 @Parsed
@Validate(nullable = false)
public void setSomeString(String value)


2 - extend class ValidatedConversion and use that class on a @Convert annotation:



public class LengthValidator extends ValidatedConversion 

private int min;
private int max;

public LengthValidator(String... args)
super(false, false); //not null / not blank
this.min = Integer.parseInt(args[0]);
this.max = Integer.parseInt(args[1]);


@Override
protected void validate(Object value)



Then add it to your attribute:



 @Parsed
@Convert(conversionClass = LengthValidator.class, args = "3", "5")
private String someString;


Hope this helps.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 4 at 1:31









Jeronimo BackesJeronimo Backes

4,8451 gold badge18 silver badges24 bronze badges




4,8451 gold badge18 silver badges24 bronze badges















  • It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

    – Jesús David López
    Apr 4 at 10:32

















  • It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

    – Jesús David López
    Apr 4 at 10:32
















It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

– Jesús David López
Apr 4 at 10:32





It helps a lot. Thanks! excellent library btw. I'm combining RegEx with ValidatedConversion and it works ... fast! :-)

– Jesús David López
Apr 4 at 10:32




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55403794%2funivocity-howto-add-parameters-to-a-custom-validator%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript