-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/minimum validation #20
Changes from all commits
4d1b690
e1058d4
9cfd4d0
1ad4041
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
export const ARTWORK_CONSTRAINTS = { | ||
title: { | ||
presence: true | ||
}, | ||
imageUrl: { | ||
presence: true, | ||
url: true | ||
}, | ||
artistId: { | ||
presence: true, | ||
personExists: true | ||
}, | ||
eventbriteId: { | ||
presence: false | ||
} | ||
title: { | ||
presence: { allowEmpty: false } | ||
}, | ||
imageUrl: { | ||
presence: { allowEmpty: false }, | ||
url: true | ||
}, | ||
artistId: { | ||
presence: { allowEmpty: false } | ||
}, | ||
eventbriteId: { | ||
presence: false | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
export const LOCATION_CONSTRAINTS = { | ||
name: { | ||
presence: true | ||
}, | ||
seatingCapacity: { | ||
presence: true, | ||
numericality: { | ||
onlyInteger: true, | ||
greaterThan: 0 | ||
} | ||
}, | ||
addressLine1: { | ||
presence: true | ||
}, | ||
addressLine2: { | ||
presence: false | ||
}, | ||
imageUrl: { | ||
presence: false, | ||
url: true | ||
}, | ||
eventbriteId: { | ||
presence: false | ||
}, | ||
name: { | ||
presence: { allowEmpty: false } | ||
}, | ||
seatingCapacity: { | ||
presence: { allowEmpty: false }, | ||
numericality: { | ||
onlyInteger: true, | ||
greaterThan: 0 | ||
} | ||
}, | ||
addressLine1: { | ||
presence: { allowEmpty: false } | ||
}, | ||
addressLine2: { | ||
presence: false | ||
}, | ||
imageUrl: { | ||
presence: false, | ||
urlAllowEmpty: true | ||
}, | ||
eventbriteId: { | ||
presence: false | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
export const ORGANISATION_CONSTRAINTS = { | ||
name: { | ||
presence: true | ||
}, | ||
about: { | ||
presence: true | ||
}, | ||
websiteUrl: { | ||
presence: false, | ||
url: true | ||
}, | ||
avatarUrl: { | ||
presence: false, | ||
url: true | ||
}, | ||
githubUrl: { | ||
presence: false, | ||
url: true | ||
} | ||
name: { | ||
presence: { allowEmpty: false } | ||
}, | ||
about: { | ||
presence: { allowEmpty: false } | ||
}, | ||
websiteUrl: { | ||
presence: false, | ||
urlAllowEmpty: true | ||
}, | ||
avatarUrl: { | ||
presence: false, | ||
urlAllowEmpty: true | ||
}, | ||
githubUrl: { | ||
presence: false, | ||
urlAllowEmpty: true | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
export const PERSON_CONSTRAINTS = { | ||
name: { | ||
presence: true | ||
}, | ||
about: { | ||
presence: true | ||
}, | ||
websiteUrl: { | ||
presence: false, | ||
url: true | ||
}, | ||
avatarUrl: { | ||
presence: false, | ||
url: true | ||
}, | ||
githubUrl: { | ||
presence: false, | ||
url: true | ||
} | ||
name: { | ||
presence: { allowEmpty: false } | ||
}, | ||
about: { | ||
presence: { allowEmpty: false } | ||
}, | ||
websiteUrl: { | ||
presence: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applies to other validation files. |
||
urlAllowEmpty: true | ||
}, | ||
avatarUrl: { | ||
presence: false, | ||
urlAllowEmpty: true | ||
}, | ||
githubUrl: { | ||
presence: false, | ||
urlAllowEmpty: true | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,10 @@ validators.array = (value: any[], options: ArrayValidatorOptions, key: string, a | |
validators.object = (value: any, options: MapValidatorOptions, key: string, attributes: any) => { | ||
return validate(value, options.constraints); | ||
}; | ||
|
||
validators.urlAllowEmpty = (values: any, ...others: any[]) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice. A bit disappointing the library does not support it by default. |
||
if (!values) return; | ||
return validators.url(values, ...others); | ||
}; | ||
|
||
export default validate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot about this one. Wouldn't have worked without this aye? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, XXXexists in the repositories also add custom validators. In that case, they should also be exported there and imported here. Not sure with this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to indentation using 4 spaces? I know this is linting issue again 🤣