Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import uuidV4 from "uuid/v4";
import Model from 'mdeditor/models/base';
import {
validator,
buildValidations
} from 'ember-cp-validations';
const Validations = buildValidations({
'recordId': validator(
'presence', {
presence: true,
ignoreBlank: true,
}),
'json.metadata.resourceInfo.resourceType': [
validator('array-valid'),
validator('array-required', {
track: ['type']
})
],
// 'json.resourceInfo.abstract': validator('presence', {
// presence: true,
// ignoreBlank: true
// }),
'json.metadata.resourceInfo.citation.title': validator('presence', {
presence: true,
ignoreBlank: true
})
// 'json.metadata.resourceInfo.citation': validator('length', {
// min: 1
// }),
// 'json.metadata.resourceInfo.status': validator('length', {
// min: 1
import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
title: {
description: 'Title',
validators: [
validator('presence', true),
validator('length', {
// minimum length for title?
max: 300,
})
]
},
abstract: {
description: 'Abstract',
validators: [
validator('presence', true),
validator('length', {
// minimum length for abstract?
max: 5000
})
]
},
doi: {
import EmberObject from '@ember/object';
import { validator, buildValidations } from 'ember-cp-validations';
export const Validations = buildValidations({
username: {
description: 'Username',
validators: [
validator('presence', true),
validator('length', {
min: 5,
max: 15
})
]
},
password: {
description: 'Password',
validators: [
validator('presence', true),
validator('length', {
min: 4,
max: 10
})
]
}
import DS from 'ember-data';
import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
source: {
description: 'Order Source',
validators: [validator('ds-error'), validator('presence', true)]
},
lines: {
description: 'Order Lines',
validators: [
validator('ds-error'),
validator('has-many'),
validator('presence', true)
]
}
});
export default DS.Model.extend(Validations, {
source: DS.attr('string'),
lines: DS.hasMany('order-line', { async: true })
});
import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
type: {
description: 'Order Line Type',
validators: [validator('ds-error'), validator('presence', true)]
},
order: {
description: 'Order',
validators: [validator('ds-error'), validator('presence', true)]
},
selections: {
description: 'Order Selections',
validators: [
validator('ds-error'),
validator('has-many'),
validator('presence', true)
]
}
});
export default DS.Model.extend(Validations, {
order: DS.belongsTo('order', { async: true }),
selections: DS.hasMany('order-selection', { async: true }),
type: DS.attr('string')
});
gte: 0
})
],
durationMinutes: [
validator('number', {
allowString: true,
integer: true,
gte: 0,
lte: 59
})
],
learnerGroups: {
dependentKeys: ['model.smallGroupMode'],
disabled: not('model.smallGroupMode'),
validators: [
validator('length', {
min: 1,
messageKey: 'general.smallGroupMessage'
})
]
},
});
export default Component.extend(ValidationErrorDisplay, Validations, {
currentUser: service(),
init(){
this._super(...arguments);
this.set('recurringDayOptions', [
{day: '0', t: 'general.sunday'},
{day: '1', t: 'general.monday'},
{day: '2', t: 'general.tuesday'},
import { attr, belongsTo } from '@ember-decorators/data';
import { buildValidations, validator } from 'ember-cp-validations';
import { Link } from 'jsonapi-typescript';
import getHref from 'ember-osf-web/utils/get-href';
import OsfModel, { OsfLinks } from './osf-model';
import UserModel from './user';
const Validations = buildValidations({
twoFactorVerification: [
validator('presence', true),
validator('number', {
allowString: true,
integer: true,
positive: true,
}),
],
});
export interface UserSettingsLinks extends OsfLinks {
export: Link;
}
export default class UserSettingModel extends OsfModel.extend(Validations) {
@attr() links!: UserSettingsLinks;
@attr('boolean') twoFactorEnabled!: boolean;
@attr('boolean') twoFactorConfirmed!: boolean;
@attr('boolean') subscribeOsfHelpEmail!: boolean;
'intervalAmount': [
validator('presence', {
presence: true,
//disabled: computed.notEmpty('model.endDateTime'),
ignoreBlank: true
})
],
'startDateTime': [
validator('presence', {
presence: true,
disabled: notEmpty('model.endDateTime'),
ignoreBlank: true
})
],
'endDateTime': [
validator('date', {
onOrAfter: alias('model.startDateTime'),
isWarning: true
}),
validator('presence', {
presence: true,
disabled: notEmpty('model.startDateTime'),
ignoreBlank: true
})
]
});
export default Component.extend(Validations, {
didReceiveAttrs() {
this._super(...arguments);
let model = get(this, 'model');
import { alias } from '@ember/object/computed';
import { isArray } from '@ember/array';
import { computed } from '@ember/object';
import Component from '@ember/component';
import {
regex
} from '../md-online-resource/component';
import {
validator,
buildValidations
} from 'ember-cp-validations';
const Validations = buildValidations({
'onlineResource': [
validator('format', {
regex: regex,
isWarning: true,
message: 'This field should be a valid, resolvable uri.',
dependentKeys: ['onlineResource', 'model.thesaurus.onlineResource.0.uri']
})
],
title: validator('presence', {
presence: true,
ignoreBlank: true
})
});
export default Component.extend(Validations, {
disabled: computed('model.thesaurus.identifier.0.identifier',
function() {
return this.get('model.thesaurus.identifier.0.identifier') !==
name: validator('presence', true),
frontendHost: [
validator('presence', true),
validator('format', {
regex: CommonValidations.host_format_with_wildcard,
message: I18n.t('errors.messages.invalid_host_format'),
}),
],
backendHost: [
validator('presence', {
presence: true,
disabled: computed('model.frontendHost', function() {
return (this.model.frontendHost && this.model.frontendHost[0] === '*');
}),
}),
validator('format', {
regex: CommonValidations.host_format_with_wildcard,
message: I18n.t('errors.messages.invalid_host_format'),
disabled: computed.not('model.backendHost'),
}),
],
});
export default Model.extend(Validations, {
name: attr(),
sortOrder: attr('number'),
backendProtocol: attr('string', { defaultValue: 'http' }),
frontendHost: attr(),
backendHost: attr(),
balanceAlgorithm: attr('string', { defaultValue: 'least_conn' }),
createdAt: attr(),
updatedAt: attr(),