Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Programming APIs with C# and .NET
  • Table Of Contents Toc
Programming APIs with C# and .NET

Programming APIs with C# and .NET

By : Jesse Liberty, Joseph Dluzen
5 (1)
close
close
Programming APIs with C# and .NET

Programming APIs with C# and .NET

5 (1)
By: Jesse Liberty, Joseph Dluzen

Overview of this book

APIs are at the heart of modern software development, enabling seamless communication between applications. In the C# and .NET ecosystem, mastering API development is key to building scalable, reliable systems that meet both client and enterprise needs. Written by C# and .NET experts Jesse Liberty and Joseph Dluzen, this book draws on their extensive experience as hands-on programmers to equip you with the tools, techniques, and best practices for creating powerful APIs. Starting with API fundamentals, it covers everything you need to design, build, and consume APIs using .NET technologies such as ASP.NET Core, and explores both controller and Function API implementations. You'll integrate essential tools such as Postman for testing to streamline your development workflow. Through practical examples and exercises, the book guides you from database creation to deploying APIs on Azure. By the end of this book, you’ll have gained real-world skills to develop secure, high-performance APIs that scale with your applications for both personal projects and enterprise-level systems.
Table of Contents (14 chapters)
close
close
11
Chapter 11: What’s Next?

Built-in validators

There is a cornucopia of built-in validators in addition to the Equal and NotEmpty validators we’ve seen so far. I won’t provide a comprehensive list (see the documentation) but one of the most interesting is the PredicateValidator validator. This passes the value of the property to a delegate, which can use custom validation logic. This is accomplished with the keyword Must keyword, as shown here:

RuleFor(car => car.Is_Deleted).Must(isDeleted => isDeleted == "0").WithMessage("Car must have value zero");

If this validation fails, the issue is displayed in the results as shown in Figure 5.5:

Figure 5.5 – PredicateValidator error

Figure 5.5 – PredicateValidator error

There is a RegularExpression validator that uses the Matches keyword (instead of Must), but one of my favorites is EmailValidator, which ensures that the value submitted is a valid email. Similarly, there is a CreditCard validator:

RuleFor(cc => cc.CreditCard...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Programming APIs with C# and .NET
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon