validation

Java scanner input validation [duplicate]

徘徊边缘 提交于 2021-01-28 09:56:03
问题 This question already has answers here : Validating input using java.util.Scanner [duplicate] (6 answers) Closed 3 years ago . I am trying to accept only three numbers from my input: 1, 2, 3. Any other different than that must be invalid. I have created method but I don't have an idea why it did not working. What must I change? int number; do { System.out.println("Enter 1, 2 or 3"); while (!scanner.hasNextInt()) { System.out.println("Invalid input!"); } number = scanner.nextInt(); } while

Is there a way to validate fields in a Request Object that am using as a wrapper, such that one of them is optional

时光毁灭记忆、已成空白 提交于 2021-01-28 08:03:30
问题 Controller Code: @RequestMapping(value="/update", method=RequestMethod.POST, produces = "application/json; charset=utf-8") @ResponseBody public ResponseEntityWrapper update( HttpServletRequest request, @RequestBody @Valid InputForm form, HttpServletResponse response ) { //logic } InputForm: public class InputForm{ @NotNull private String formId; private List<Employee> addEmpList; private List<Employee> removeEmpList; //Other fields & getters & setters..... } Employee: public Employee{

confusionMatrix for logistic regression in R

我怕爱的太早我们不能终老 提交于 2021-01-28 07:52:52
问题 I want to calculate two confusion matrix for my logistic regression using my training data and my testing data: logitMod <- glm(LoanStatus_B ~ ., data=train, family=binomial(link="logit")) i set the threshold of predicted probability at 0.5: confusionMatrix(table(predict(logitMod, type="response") >= 0.5, train$LoanStatus_B == 1)) And the the code below works well for my training set. However, when i use the test set: confusionMatrix(table(predict(logitMod, type="response") >= 0.5, test

Symfony ValidatorComponent > AnnotationMapping in FormComponent

喜欢而已 提交于 2021-01-28 07:26:46
问题 Im working on a project where I'm using some Symfony Components. My problem is how to make the Form Component's validation of Forms use AnnotationMapping to find the constraints. SetUp: global $loader; //composer - autoload AnnotationRegistry::registerLoader([$loader, 'loadClass']); $validator = Validation::createValidatorBuilder() ->enableAnnotationMapping() ->getValidator(); $formFactory = Forms::createFormFactoryBuilder() [...] ->addExtension(new ValidatorExtension($validator)) -

validate an non-Input model in MVC core

十年热恋 提交于 2021-01-28 07:12:29
问题 I have an action-method that have an object type Input like this: public async Task<IActionResult> DoSomeThing([FromBody]object input, bool options) { if (options == true) { var castedInput = (A) input; if (TryValidateModel(castedInput)) { // do some thing } else { //return validation Errors; //forexample:return Error("Error1") //??!??!!??!?!?!?!??! } } else { var castedInput = (B)input; if (TryValidateModel(castedInput)) { // do some thing } else { //return validation Errors; //forexample

How to keep input after failed form validation in flask

若如初见. 提交于 2021-01-28 05:21:33
问题 With django I could simply pass the POST data to the form after failed validation and the user would not have to enter everything again: question_form = QuestionForm(request.POST) choice_form_set = ChoiceFormSet(request.POST) How could I implement this on my own in flask? 回答1: It's pretty similarly possible with Flask as well: @app.route('/register', methods=['GET', 'POST']) def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): user = User(form

Why does the HTML validator give me an error about this HTML comment?

江枫思渺然 提交于 2021-01-28 05:15:54
问题 This is just question about comments inside of an HTML page. For example: <html> <head></head> <body> <!-- <p><font size="4">--</font></p> --> </body> </html> Using http://validator.w3.org/check I get the following error message. Does it make sense? Line 6, Column 21: invalid comment declaration: found character "<" outside comment but inside comment declaration <p><font size="4">--</font></p> Check that you are using a proper syntax for your comments, e.g: . This error may appear if you

Conditional/cascading/dependent drop-down list

为君一笑 提交于 2021-01-28 04:08:24
问题 I am essentially trying to do that this guy is trying to do: Excel drop-down list using vLookup I've gone through the steps and since my data set has about 400 different drop down options I am hoping there is an easier way than naming ranges. I have a list of about 400 different account names. Each of these account names is tied to a household and identified by the household ID number. A household can have anywhere from 1-5 account names. I would like for my drop down menu to be able to

Validate minimum length of parameter in Spring Jpa Query

不打扰是莪最后的温柔 提交于 2021-01-28 03:51:56
问题 We have a data object Foo that has a string property Bar, and a jpa repository with a method to find Foo by Bar: @Entity @Table(name = "FOO") public class Foo { @Id @GeneratedValue private Long id; @Column(name = "BAR", length = 16, nullable = false) private String bar; public String getBar() { return bar; } public void setBar(String bar) { this.bar = bar; } } public interface FooJpaRepository extends JpaRepository<Foo, Long> { @Transactional(propagation = Propagation.REQUIRED, readOnly =

Laravel Validation with or

﹥>﹥吖頭↗ 提交于 2021-01-28 02:55:50
问题 I have a laravel validation that needs to match one of the 3 regex's $validatedData = $request->validate([ 'BCH-address' => 'regex:/^([13][a-km-zA-HJ-NP-Z1-9]{25,34})/', 'BCH-address' => 'regex:/^((bitcoincash:)?(q|p)[a-z0-9]{41})/', 'BCH-address' => 'regex:/^((BITCOINCASH:)?(Q|P)[A-Z0-9]{41})$/', ]), Is there a way to use a OR condition for the validation?? 回答1: You can add rule https://laravel.com/docs/5.6/validation#using-rule-objects and there your logic, or use closure https://laravel