Skip to content
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

Remove Ember. from doc strings #744

Merged
merged 1 commit into from
Nov 8, 2023
Merged
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
46 changes: 27 additions & 19 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import Validator from './validations/validator';
* ```javascript
* // models/user.js
*
* import Ember from 'ember';
* import DS from 'ember-data';
* import { validator, buildValidations } from 'ember-cp-validations';
*
* const Validations = buildValidations({
Expand Down Expand Up @@ -60,6 +58,8 @@ import Validator from './validations/validator';
* ```javascript
* // models/user.js
*
* import Model from '@ember-data/model';
*
* export default Model.extend(Validations, {
* 'username': attr('string'),
* 'password': attr('string'),
Expand All @@ -69,45 +69,48 @@ import Validator from './validations/validator';
*
* ## Objects
*
* You can also use the generated `Validations` mixin on any `Ember.Object` or child
* of `Ember.Object`, like `Ember.Component`. For example:
* You can also use the generated `Validations` mixin on any `EmberObject` or child
* of `EmberObject`, like `Component`. For example:
*
* ```javascript
* // components/x-foo.js
*
* import Ember from 'ember';
* import Component from '@ember/component';
* import { validator, buildValidations } from 'ember-cp-validations';
*
* const Validations = buildValidations({
* bar: validator('presence', true)
* });
*
* export default Ember.Component.extend(Validations, {
* export default Component.extend(Validations, {
* bar: null
* });
* ```
*
* ```javascript
* // models/user.js
*
* export default Ember.Object.extend(Validations, {
* import EmberObject from '@ember/object';
*
* export default EmberObject.extend(Validations, {
* username: null
* });
* ```
*
* ## A Note on Testing & Object Containers
*
* To lookup validators, container access is required, which can cause an issue with `Ember.Object` creation
* To lookup validators, container access is required, which can cause an issue with `EmberObject` creation
* if the object is statically imported. The current fix for this is as follows.
*
* **Ember < 2.3.0**
*
* ```javascript
* // routes/index.js
*
* import Route from '@ember/routing/route';
* import User from '../models/user';
*
* export default Ember.Route.extend({
* export default Route.extend({
* model() {
* const container = this.get('container');
* return User.create({ username: 'John', container })
Expand All @@ -120,12 +123,14 @@ import Validator from './validations/validator';
* ```javascript
* // routes/index.js
*
* import { getOwner } from '@ember/application';
* import Route from '@ember/routing/route';
* import User from '../models/user';
*
* export default Ember.Route.extend({
* export default Route.extend({
* model() {
* return User.create(
* Ember.getOwner(this).ownerInjection(),
* getOwner(this).ownerInjection(),
* { username: 'John' }
* );
* }
Expand Down Expand Up @@ -203,7 +208,6 @@ import Validator from './validations/validator';
* ```
*
* ```javascript
* import Ember from 'ember';
* import { validator, buildValidations } from 'ember-cp-validations';
*
* const Validations = buildValidations({
Expand Down Expand Up @@ -237,12 +241,15 @@ import Validator from './validations/validator';
* Please note that the `message` option of a validator can also be a function with [the following signature](http://adopted-ember-addons.github.io/ember-cp-validations/docs/modules/Validators.html#message).
*
* ```javascript
* import { computed } from '@ember/object';
* import { not, readOnly } from '@ember/object/computed';
*
* const Validations = buildValidations({
* username: validator('length', {
* disabled: Ember.computed.not('model.meta.username.isEnabled'),
* min: Ember.computed.readOnly('model.meta.username.minLength'),
* max: Ember.computed.readOnly('model.meta.username.maxLength'),
* description: Ember.computed('model', 'attribute', function() {
* disabled: not('model.meta.username.isEnabled'),
* min: readOnly('model.meta.username.minLength'),
* max: readOnly('model.meta.username.maxLength'),
* description: computed('model', 'attribute', function() {
* // CPs have access to the `model` and `attribute`
* return this.get('model').generateDescription(this.get('attribute'));
* })
Expand All @@ -255,7 +262,8 @@ import Validator from './validations/validator';
* When declaring object validations (not including Ember Data models), it is possible to validate child objects from the parent object.
*
* ```javascript
* import Ember from 'ember';
* import Component from '@ember/component';
* import { alias } from '@ember/object/computed';
* import { validator, buildValidations } from 'ember-cp-validations';
*
* const Validations = buildValidations({
Expand All @@ -265,7 +273,7 @@ import Validator from './validations/validator';
* 'user.account.number': validator('number')
* });
*
* export default Ember.Component.extend(Validations, {
* export default Component.extend(Validations, {
* acceptTerms: false,
* user: {
* firstName: 'John',
Expand All @@ -274,7 +282,7 @@ import Validator from './validations/validator';
* number: 123456,
* }
* },
* isFormValid: Ember.computed.alias('validations.isValid'),
* isFormValid: alias('validations.isValid'),
* });
* ```
*
Expand Down
2 changes: 1 addition & 1 deletion addon/utils/deep-set.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Assigns a value to an object via the given path while creating new objects if
* the pathing requires it. If the given path is `foo.bar`, it will create a new object (obj.foo)
* and assign value to obj.foo.bar. If the given object is an Ember.Object, it will create new Ember.Objects.
* and assign value to obj.foo.bar. If the given object is an EmberObject, it will create new EmberObjects.
*/
import { isDescriptor } from './utils';
import { isNone } from '@ember/utils';
Expand Down
4 changes: 2 additions & 2 deletions addon/validations/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function normalizeOptions(validations = {}, globalOptions = {}) {
* @param {Object} inheritedValidationsClass
* @param {Object} validations
* @param {Object} model
* @return {Ember.Object}
* @return {EmberObject}
*/
function createValidationsClass(inheritedValidationsClass, validations, model) {
let validationRules = {};
Expand Down Expand Up @@ -307,7 +307,7 @@ function createValidationsClass(inheritedValidationsClass, validations, model) {
* @param {Object} validatableAttributes
* @param {Object} validationRules
* @param {Object} model
* @return {Ember.Object}
* @return {EmberObject}
*/
function createAttrsClass(validatableAttributes, validationRules, model) {
let nestedClasses = {};
Expand Down
4 changes: 2 additions & 2 deletions addon/validators/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ export default Base;
* ```javascript
* // app/validators/unique-username.js
*
* import Ember from 'ember';
* import { service } from '@ember/service';
* import BaseValidator from 'ember-cp-validations/validators/base';
*
* const UniqueUsername = BaseValidator.extend({
* store: Ember.inject.service(),
* store: service(),
*
* validate(value, options, model, attribute) {
* return this.get('store').findRecord('user', value).then((user) => {
Expand Down
8 changes: 5 additions & 3 deletions addon/validators/belongs-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
/**
* <i class="fa fa-hand-o-right" aria-hidden="true"></i> [See All Options](#method_validate)
*
* Identifies a `belongs-to` relationship in an Ember Data Model or Ember.Object.
* Identifies a `belongs-to` relationship in an Ember Data Model or EmberObject.
* This is used to create a link to the validations object of the child model.
*
* _**Note:** Validations must exist on **both** models/objects_
Expand Down Expand Up @@ -42,18 +42,20 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
* ```javascript
* // model/users.js
*
* import { getOwner } from '@ember/application';
* import EmberObject from '@ember/object';
* import UserDetails from '../user-details';
*
* const Validations = buildValidations({
* details: validator('belongs-to')
* });
*
* export default Ember.Object.extend(Validations, {
* export default EmberObject.extend(Validations, {
* details: null,
*
* init() {
* this._super(...arguments);
* let owner = Ember.getOwner(this);
* let owner = getOwner(this);
* this.set('details', UserDetails.create(owner.ownerInjection()));
* }
* });
Expand Down
6 changes: 4 additions & 2 deletions addon/validators/has-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
/**
* <i class="fa fa-hand-o-right" aria-hidden="true"></i> [See All Options](#method_validate)
*
* Identifies a `has-many` relationship in an Ember Data Model or Ember.Object.
* Identifies a `has-many` relationship in an Ember Data Model or EmberObject.
* This is used to create a validation collection of the `has-many` validations.
*
* _**Note:** Validations must exist on **all** models/objects_
Expand All @@ -28,11 +28,13 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
* ```javascript
* // model/users.js
*
* import EmberObject from '@ember/object';
*
* const Validations = buildValidations({
* friends: validator('has-many')
* });
*
* export default Ember.Object.extend(Validations, {
* export default EmberObject.extend(Validations, {
* friends: null
* });
* ```
Expand Down
Loading