File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
src/api/middleware/validators Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ ADMIN_PASSWORD=n1j0bs_ftw.12345
3535
3636# List of regexes or url's specifying allowed origins. Example:
3737# ACCESS_CONTROL_ALLOW_ORIGINS=["https:\\/\\/deploy-preview-\\d+--nijobs\\.netlify\\.app", "https://nijobs.netlify.app"]
38- ACCESS_CONTROL_ALLOW_ORIGINS =
38+ ACCESS_CONTROL_ALLOW_ORIGINS = ["https:\\/\\/deploy-preview-\\d+--nijobs\\.netlify\\.app", "https://nijobs.netlify.app","https://localhost"]
3939
4040# Mail service information. If you don't provide a MAIL_FROM, no emails will be sent. The app will execute no-ops and won't crash
4141# However, if you want to send emails, you need to fill all of the following 2 fields
Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ import {
1818import * as companyMiddleware from "../company.js" ;
1919import config from "../../../config/env.js" ;
2020import { validApplyURL } from "../../../models/modelUtils.js" ;
21+ const jobMinDurationMustNotExistInFreelance = ( jobMinDuration , { req } ) => {
22+ if ( req . body . jobType !== "FREELANCE" ) return true ;
23+ if ( jobMinDuration !== null && jobMinDuration !== undefined ) {
24+ throw new Error ( ValidationReasons . FREELANCE_OFFER_CANT_HAVE_MIN_DURATION ) ;
25+ }
26+ return true ;
27+ } ;
2128
2229const jobMaxDurationGreaterOrEqualThanJobMinDuration = ( jobMaxDuration , { req } ) => {
2330
@@ -82,6 +89,7 @@ export const create = useExpressValidators([
8289
8390
8491 body ( "jobMinDuration" , ValidationReasons . DEFAULT )
92+ . custom ( jobMinDurationMustNotExistInFreelance )
8593 . if ( ( value , { req } ) => req . body . jobType !== "FREELANCE" )
8694 . exists ( ) . withMessage ( ValidationReasons . REQUIRED ) . bail ( )
8795 . isInt ( ) . withMessage ( ValidationReasons . INT ) ,
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ const ValidationReasons = Object.freeze({
5050 OFFER_HIDDEN : "offer-is-hidden" ,
5151 FILE_TOO_LARGE : ( max ) => `file-cant-be-larger-than-${ max } MB` ,
5252 MUST_BE_GREATER_THAN_OR_EQUAL_TO : ( field ) => `must-be-greater-than-or-equal-to:${ field } ` ,
53+ FREELANCE_OFFER_CANT_HAVE_MIN_DURATION : "freelance-offer-cant-have-min-duration" ,
5354} ) ;
5455
5556export default ValidationReasons ;
You can’t perform that action at this time.
0 commit comments