Nizamuddin Siddiqui has Published 2307 Articles

How to check Minlength and Maxlength validation of a property in C# using Fluent Validation?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 25-Nov-2020 11:46:46

2K+ Views

MaxLength ValidatorEnsures that the length of a particular string property is no longer than the specified value.Only valid on string propertiesString format args:{PropertyName} = The name of the property being validated{MaxLength} = Maximum length{TotalLength} = Number of characters entered{PropertyValue} = The current value of the propertyMinLength ValidatorEnsures that the length ... Read More

How to valid DateofBirth using fluent Validation in C# if it exceeds current year?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 25-Nov-2020 11:44:03

3K+ Views

To specify a validation rule for a particular property, call the RuleFor method, passing a lambda expression that indicates the property that you wish to validateRuleFor(p => p.DateOfBirth)To run the validator, instantiate the validator object and call the Validate method, passing in the object to validate.ValidationResult results = validator.Validate(person);The Validate ... Read More

What is use of fluent Validation in C# and how to use in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 25-Nov-2020 11:41:41

2K+ Views

FluentValidation is a .NET library for building strongly-typed validation rules. It Uses a fluent interface and lambda expressions for building validation rules. It helps clean up your domain code and make it more cohesive, as well as giving you a single place to look for validation logicTo make use of ... Read More

How to copy files into a directory in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 25-Nov-2020 11:37:24

3K+ Views

To Copy a file, C# provides a method File. CopyFile. Copy has 2 overloadsCopy(String, String) -Copies an existing file to a new file. Overwriting a file of the same name is not allowed.Copy(String, String, Boolean) Copies an existing file to a new file. Overwriting a file of the same name ... Read More

What are the different ways to implement dependency injection and their advantages in C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 25-Nov-2020 11:33:47

2K+ Views

The process of injecting (converting) coupled (dependent) objects into decoupled (independent) objects is called Dependency Injection.Types of Dependency InjectionThere are four types of DI:1.Constructor Injection2.Setter Injection3.Interface-based injection4.Service Locator InjectionConstructor InjectionConstructor is used to interface parameter that exposed through the parameterized contractor.It injects the dependencies through a contractor method as object ... Read More

How to convert XML to Json and Json back to XML using Newtonsoft.json?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 25-Nov-2020 11:32:31

2K+ Views

Json.NET supports converting JSON to XML and vice versa using the XmlNodeConverter.Elements, attributes, text, comments, character data, processing instructions, namespaces, and the XML declaration are all preserved when converting between the twoSerializeXmlNodeThe JsonConvert has two helper methods for converting between JSON and XML. The first is SerializeXmlNode(). This method takes ... Read More

How to subset a data frame by excluding the column names that are stored in a vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:59:47

523 Views

Subsetting of a data frame can be done in many ways and one such say is selecting the columns that are stored in a vector. Suppose we have a data frame df that has columns x, y, and z and the column names y and z are stored in a ... Read More

How to convert a named vector to a list in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:57:44

423 Views

A named vector cannot be directly converted to a list because we would need to un-name the vector names and convert those names to names of the list elements. This can be done by using lapply function function. For example, suppose we have a named vector x then it can ... Read More

How to find the correlation coefficient between two data frames in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:55:50

4K+ Views

If two data frames in R have equal number of columns then we can find the correlation coefficient among the columns of these data frames which will be the correlation matrix. For example, if we have a data frame df1 that contains column x and y and another data frame ... Read More

How to add a straight line to a plot in R starting from bottom left and ending at top right?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 23-Nov-2020 10:53:16

111 Views

The abline function can give us a straight line from intercept 0 with slope 1 in an existing plot. We would need to pass the coefficients inside the function as abline(coef = c(0, 1)). Therefore, we can use this function to add a line starting from bottom left and ending ... Read More

Advertisements