mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-15 15:10:31 -08:00
Fix optional fields are unexpectedly set to be required (#142)
This commit is contained in:
parent
1299ab9156
commit
758072395e
1 changed files with 5 additions and 3 deletions
|
|
@ -10,20 +10,20 @@ const kits = {
|
|||
return null;
|
||||
},
|
||||
url: (val, maxLength, fieldName) => {
|
||||
if (!isUrl(val)) {
|
||||
if (val && !isUrl(val)) {
|
||||
return '{fieldName} is not valid.'.replace('{fieldName}', fieldName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// accept link without protocol prefix
|
||||
lessStrictUrl: (val, _, fieldName) => {
|
||||
if (!isUrl(val) && !isUrl(`http://${val}`)) {
|
||||
if (val && !isUrl(val) && !isUrl(`http://${val}`)) {
|
||||
return '{fieldName} is not valid.'.replace('{fieldName}', fieldName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
licenseKey: (val, ruleVal, fieldName) => {
|
||||
if (!isValidLicenseKey(val)) {
|
||||
if (val && !isValidLicenseKey(val)) {
|
||||
return '{fieldName} is not valid.'.replace('{fieldName}', fieldName);
|
||||
}
|
||||
return null;
|
||||
|
|
@ -34,6 +34,8 @@ const validate = (changes, rules) => {
|
|||
const newChanges = { ...changes };
|
||||
|
||||
Object.keys(changes).forEach((key) => {
|
||||
if (key.endsWith('Error')) return;
|
||||
|
||||
let err = null;
|
||||
|
||||
const val = newChanges[key];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue