Skip to content

Validations checks for title and description #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Classy.DotNet.Mvc/Controllers/ListingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,14 @@ public ActionResult EditListing(UpdateListingViewModel<TListingMetadata> model)

Dictionary<string, string> errors = new Dictionary<string, string>();

if (string.IsNullOrWhiteSpace(model.Title))
{
errors.Add("Title", Localizer.Get("CreateListing_TitleRequired"));
}
if (string.IsNullOrWhiteSpace(model.Content))
{
errors.Add("Content", Localizer.Get("CreateListing_ContentRequired"));
}
if (string.IsNullOrWhiteSpace(Request["Categories[]"]))
{
errors.Add("Categories", Localizer.Get("CreateListing_CategoryRequired"));
Expand Down
14 changes: 14 additions & 0 deletions MyHome/Deployment/Resources/edit-product.resm
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@
"Values": {
"en": "Please provide basic product info"
}
},
{
"Key": "CreateListing_ContentRequired",
"Description": "Description required validation message",
"Values": {
"en": "Description is required"
}
},
{
"Key": "CreateListing_TitleRequired",
"Description": "Title required validation message",
"Values": {
"en": "Title is required"
}
}
]
}
Expand Down
1 change: 1 addition & 0 deletions MyHome/Views/Product/CreateProduct.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
$(".overlay").hide();
var fields = ["Title", "Content", "ProductUrl", "SKU", "CompareAtPrice", "Price", "Quantity", "Width", "Depth", "Height"];
$("#globalVS").toggleClass("hidden", true);
$("#globalVS").find("ul").html("");
if (response.errors) {
for (var i = 0; i < fields.length; i++) {
if (response.errors[fields[i]]){
Expand Down
1 change: 1 addition & 0 deletions MyHome/Views/Product/EditProduct.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
$(".overlay").hide();
var fields = ["Title", "Content", "ProductUrl", "SKU", "CompareAtPrice", "Price", "Quantity", "Width", "Depth", "Height"];
$("#globalVS").toggleClass("hidden", true);
$("#globalVS").find("ul").html("");
if (response.errors) {
for (var i = 0; i < fields.length; i++) {
if (response.errors[fields[i]]){
Expand Down