How to fix the validation to be better?

validation error message examples
need for validation psychology
examples of validating statements
form validation messages example
validation messages list
how to stop seeking validation in relationships
how to validate a woman

Im doing a phone validation for 2 brands and both validation have almost the same meaning only different digits.

        if (!MobileFormat(num, brand,currency))
            if (brand.Equals(Brand.LED.ToString()))
                key = "The number of phone numbers must be "9" digits.";
                key = "The number of phone numbers must be "10" digits.";


i expect the key to be in single line and not double and only change the digit.

try below:

key = string.Format("The number of phone numbers must be {0} digits.", brand.Equals(Brand.LED.ToString()) ? 9 : 10);

Understanding Validation: A Way to Communicate Acceptance , One of the four options we have in any problem situation is acceptance. There is nothing to make her response more understandable in� A simple strategy can improve your relationships. One of the four options we have in any problem situation is acceptance. Validation is one way that we communicate acceptance of ourselves and others.

Just capture digit value before building a string.

if (!MobileFormat(num, brand, currency))
    var digits = brand.Equals(Brand.LED.ToString()) ? 9 : 10;
    key = $"The number of phone numbers must be '{digits}' digits.";

With two lines you quickly recognise that two operations involved and saves some horizontal space.

Stop Seeking Validation from Others, We look to our parents for recognition (validation) that we did a good thing. The problem arises when self-validation is not possible or is not� In order to get this validation, you will likely adopt a number of toxic strategies. You’ll either try to out aloof their aloofness (“Mr. Cool Guy”). Degrade their self-esteem (“Mr. Asshole Guy”). Be incredibly nice to them so that they’ll owe you something (“Mr. Nice Guy”), and so on.

If either string is nullable, then can do this:

if (!MobileFormat(num, brand, currency))
     key = $"The number of phone numbers must be {(Equals(brand, Brand.LED.ToString()) ? 9 : 10)} digits";

Improve Validation Errors with Adaptive Messages, Luckily, testing also revealed a solution to this problem: adaptive error A much improved validation error experience that the user can easily� To Fix or to Validate? It can make a huge difference types of communication patterns in this type of situation —a make-it-better approach, and a validate-the-pain approach. is a make-it

10 Reasons Why Your Code Won't Validate (And How to Fix it), Alternately, some "fixes" can cause more errors, if done improperly. Re-validating after each attempt can ensure that you're completely fixing� The basic principle behind validation therapy is to communicate with respect, showing that their opinions and beliefs are heard, acknowledged, valued and esteemed, rather than dismissed or marginalized. It may require you to do so even when you don't agree with or believe what has been shared.

Web Form Validation: Best Practices and Tutorials — Smashing , You can read more about validation with Ajax in this excellent tutorial Users will be able to fix the errors only after they try to submit the form� Hell, part of why I wanted to get better with women was because I wanted to throw it in the faces of everyone who knew me when I was the One Who Wasn’t Good With Girls; I wanted them to marvel at how much I’d changed and validate me as a ladies’ man. You just need to make sure that you’re choosing the goals and standards you pursue

The Magic of Validation, The only problem with validation is that at first, it's really hard to do. When a person doesn't feel heard, she just clings more tightly to her own� These are all perfectly valid approaches to feeling better, but they all hinge on praise and external support. Getting help from others is only one part of the equation. We also need to be able to validate, support, and help ourselves.

  • Why not use a ternary operator if you have only if and else?
  • The first if statement is ok as for the second one you can use Ternary Operators. and as for you it would look something like key = brand.Equals(Brand.LED.ToString()) ? "The number of phone numbers must be "9" digits." : "The number of phone numbers must be "10" digits.";