Skip to content

Commit

Permalink
Forgotten inclusion documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Offir Golan committed Oct 21, 2015
1 parent 98c3292 commit 8c8c682
Show file tree
Hide file tree
Showing 24 changed files with 509 additions and 27 deletions.
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pages:
- 'Common Options': 'validators/common.md'
- 'Base': 'validators/base.md'
- 'Presence': 'validators/presence.md'
- 'Inclusion': 'validators/inclusion.md'
- 'Exclusion': 'validators/exclusion.md'
- 'Length': 'validators/length.md'
- 'Date': 'validators/date.md'
Expand Down
11 changes: 9 additions & 2 deletions tests/dummy/public/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@



<li class="toctree-l1 ">
<a class="" href="validators/inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="validators/exclusion/index.html">Exclusion</a>

Expand Down Expand Up @@ -333,7 +340,7 @@ <h2 id="basic-usage-objects">Basic Usage - Objects</h2>
export default Ember.Route.extend({
model() {
var container = this.get('container');
return User.create({ container })
return User.create({ username: 'John', container })
}
});
</code></pre>
Expand Down Expand Up @@ -440,5 +447,5 @@ <h2 id="advanced-usage">Advanced Usage</h2>

<!--
MkDocs version : 0.14.0
Build Date UTC : 2015-10-07 04:46:58.062066
Build Date UTC : 2015-10-21 18:54:10.430735
-->
7 changes: 7 additions & 0 deletions tests/dummy/public/docs/messages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@



<li class="toctree-l1 ">
<a class="" href="../validators/inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="../validators/exclusion/index.html">Exclusion</a>

Expand Down
14 changes: 12 additions & 2 deletions tests/dummy/public/docs/mkdocs/search_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"docs": [
{
"location": "/index.html",
"text": "A Ruby on Rails inspired model validation framework that is completely and utterly computed property based.\n\n\nInstallation\n\n\nember install ember-cp-validations\n\n\n\n\nLive Demo\n\n\nA live demo can be found \nhere\n\n\nBasic Usage - Models\n\n\nThe first thing we need to do it build our validation rules. This will then generate a Mixin that you will be able to incorporate into your model or object.\n\n\n// models/user.js\n\nimport Ember from 'ember';\nimport DS from 'ember-data';\nimport {\n validator, buildValidations\n}\nfrom 'ember-cp-validations';\n\nvar Validations = buildValidations({\n username: validator('presence', true),\n password: [\n validator('presence', true),\n validator('length', {\n min: 4,\n max: 8\n })\n ],\n email: [\n validator('presence', true),\n validator('format', { type: 'email' })\n ],\n emailConfirmation: [\n validator('presence', true),\n validator('confirmation', {\n on: 'email',\n message: 'do not match',\n description: 'Email addresses'\n })\n ]\n});\n\n\n\n\nOnce our rules are created and our Mixin is generated, all we have to do is add it to our model.\n\n\n// models/user.js\n\nexport default DS.Model.extend(Validations, {\n 'username': attr('string'),\n 'password': attr('string'),\n 'email': attr('string')\n});\n\n\n\n\nBasic Usage - Objects\n\n\nYou can also use the generated \nValidations\n mixin on any \nEmber.Object\n or child\nof \nEmber.Object\n, like \nEmber.Component\n. For example:\n\n\n// components/x-foo.js\n\nimport Ember from 'ember';\nimport {\n validator, buildValidations\n}\nfrom 'ember-cp-validations';\n\nvar Validations = buildValidations({\n bar: validator('presence', true)\n});\n\nexport default Ember.Component.extend(Validations, {\n bar: null\n});\n\n\n\n\nTo lookup validators, container access is required which can cause an issue with \nEmber.Object\n creation if the object is statically imported. The current fix for this is as follows. \n\n\n// models/user.js\n\nexport default Ember.Object.extend(Validations, {\n username: null\n});\n\n\n\n\n// routes/index.js\n\nimport User from '../models/user';\n\nexport default Ember.Route.extend({\n model() {\n var container = this.get('container');\n return User.create({ container })\n }\n});\n\n\n\n\nAdvanced Usage\n\n\nDefault Options\n\n\nDefault options can be specified over a set of validations for a given attribute. Local properties will always take precedence.\n\n\nInstread of doing the following:\n\n\nvar Validations = buildValidations({\n username: [\n validator('presence', {\n presence: true,\n description: 'Username'\n }),\n validator('length', {\n min: 1,\n description: 'Username'\n }),\n validator('no-whitespace-around', {\n description: 'Username'\n })\n ]\n});\n\n\n\n\nWe can declare default options: \n\n\nvar Validations = buildValidations({\n username: {\n description: 'Username'\n validators: [\n validator('presence', true),\n validator('length', {\n min: 1\n }),\n validator('no-whitespace-around', {\n description: 'A username'\n })\n ]\n },\n});\n\n\n\n\nIn the above example, all the validators for username will have a description of \nUsername\n except that of the \nno-whitespace-around\n validator which will be \nA username\n.\n\n\nOptions as Functions\n\n\nAll options can be functions which are processed lazily before validate is called. These functions have the context of the validator that is being executed, giving you access to all its properties such as options, model, attribute, etc. \n\n\nPlease note that the \nmessage\n option of a validator has its \nown signature\n.\n\n\nvar Validations = buildValidations({\n password: validator('format', {\n description() {\n return this.get('model.meta.password.description');\n },\n regex() {\n return this.get('model.meta.password.regex');\n }\n })\n});",
"text": "A Ruby on Rails inspired model validation framework that is completely and utterly computed property based.\n\n\nInstallation\n\n\nember install ember-cp-validations\n\n\n\n\nLive Demo\n\n\nA live demo can be found \nhere\n\n\nBasic Usage - Models\n\n\nThe first thing we need to do it build our validation rules. This will then generate a Mixin that you will be able to incorporate into your model or object.\n\n\n// models/user.js\n\nimport Ember from 'ember';\nimport DS from 'ember-data';\nimport {\n validator, buildValidations\n}\nfrom 'ember-cp-validations';\n\nvar Validations = buildValidations({\n username: validator('presence', true),\n password: [\n validator('presence', true),\n validator('length', {\n min: 4,\n max: 8\n })\n ],\n email: [\n validator('presence', true),\n validator('format', { type: 'email' })\n ],\n emailConfirmation: [\n validator('presence', true),\n validator('confirmation', {\n on: 'email',\n message: 'do not match',\n description: 'Email addresses'\n })\n ]\n});\n\n\n\n\nOnce our rules are created and our Mixin is generated, all we have to do is add it to our model.\n\n\n// models/user.js\n\nexport default DS.Model.extend(Validations, {\n 'username': attr('string'),\n 'password': attr('string'),\n 'email': attr('string')\n});\n\n\n\n\nBasic Usage - Objects\n\n\nYou can also use the generated \nValidations\n mixin on any \nEmber.Object\n or child\nof \nEmber.Object\n, like \nEmber.Component\n. For example:\n\n\n// components/x-foo.js\n\nimport Ember from 'ember';\nimport {\n validator, buildValidations\n}\nfrom 'ember-cp-validations';\n\nvar Validations = buildValidations({\n bar: validator('presence', true)\n});\n\nexport default Ember.Component.extend(Validations, {\n bar: null\n});\n\n\n\n\nTo lookup validators, container access is required which can cause an issue with \nEmber.Object\n creation if the object is statically imported. The current fix for this is as follows. \n\n\n// models/user.js\n\nexport default Ember.Object.extend(Validations, {\n username: null\n});\n\n\n\n\n// routes/index.js\n\nimport User from '../models/user';\n\nexport default Ember.Route.extend({\n model() {\n var container = this.get('container');\n return User.create({ username: 'John', container })\n }\n});\n\n\n\n\nAdvanced Usage\n\n\nDefault Options\n\n\nDefault options can be specified over a set of validations for a given attribute. Local properties will always take precedence.\n\n\nInstread of doing the following:\n\n\nvar Validations = buildValidations({\n username: [\n validator('presence', {\n presence: true,\n description: 'Username'\n }),\n validator('length', {\n min: 1,\n description: 'Username'\n }),\n validator('no-whitespace-around', {\n description: 'Username'\n })\n ]\n});\n\n\n\n\nWe can declare default options: \n\n\nvar Validations = buildValidations({\n username: {\n description: 'Username'\n validators: [\n validator('presence', true),\n validator('length', {\n min: 1\n }),\n validator('no-whitespace-around', {\n description: 'A username'\n })\n ]\n },\n});\n\n\n\n\nIn the above example, all the validators for username will have a description of \nUsername\n except that of the \nno-whitespace-around\n validator which will be \nA username\n.\n\n\nOptions as Functions\n\n\nAll options can be functions which are processed lazily before validate is called. These functions have the context of the validator that is being executed, giving you access to all its properties such as options, model, attribute, etc. \n\n\nPlease note that the \nmessage\n option of a validator has its \nown signature\n.\n\n\nvar Validations = buildValidations({\n password: validator('format', {\n description() {\n return this.get('model.meta.password.description');\n },\n regex() {\n return this.get('model.meta.password.regex');\n }\n })\n});",
"title": "Home"
},
{
Expand All @@ -22,7 +22,7 @@
},
{
"location": "/index.html#basic-usage-objects",
"text": "You can also use the generated Validations mixin on any Ember.Object or child\nof Ember.Object , like Ember.Component . For example: // components/x-foo.js\n\nimport Ember from 'ember';\nimport {\n validator, buildValidations\n}\nfrom 'ember-cp-validations';\n\nvar Validations = buildValidations({\n bar: validator('presence', true)\n});\n\nexport default Ember.Component.extend(Validations, {\n bar: null\n}); To lookup validators, container access is required which can cause an issue with Ember.Object creation if the object is statically imported. The current fix for this is as follows. // models/user.js\n\nexport default Ember.Object.extend(Validations, {\n username: null\n}); // routes/index.js\n\nimport User from '../models/user';\n\nexport default Ember.Route.extend({\n model() {\n var container = this.get('container');\n return User.create({ container })\n }\n});",
"text": "You can also use the generated Validations mixin on any Ember.Object or child\nof Ember.Object , like Ember.Component . For example: // components/x-foo.js\n\nimport Ember from 'ember';\nimport {\n validator, buildValidations\n}\nfrom 'ember-cp-validations';\n\nvar Validations = buildValidations({\n bar: validator('presence', true)\n});\n\nexport default Ember.Component.extend(Validations, {\n bar: null\n}); To lookup validators, container access is required which can cause an issue with Ember.Object creation if the object is statically imported. The current fix for this is as follows. // models/user.js\n\nexport default Ember.Object.extend(Validations, {\n username: null\n}); // routes/index.js\n\nimport User from '../models/user';\n\nexport default Ember.Route.extend({\n model() {\n var container = this.get('container');\n return User.create({ username: 'John', container })\n }\n});",
"title": "Basic Usage - Objects"
},
{
Expand Down Expand Up @@ -125,6 +125,16 @@
"text": "If \ntrue\n validates that the given value is not empty, if \nfalse\n, validates that the given value is empty.\n\n\n// Examples\nvalidator('presence', true)\nvalidator('presence', false)\nvalidator('presence', {\n presence: true,\n message: 'should not be empty'\n})",
"title": "Presence"
},
{
"location": "/validators/inclusion/index.html",
"text": "Validates that the attributes\u2019 values are included in a given list. All comparisons are done using strict equality so type matters! For range, the value type is checked against both lower and upper bounds for type equality.\n\n\nOptions\n\n\n\n\nallowBlank\n (\nBoolean\n): If true, skips validation if the value is empty\n\n\nin\n (\nArray\n): The list of values this attribute could be\n\n\nrange\n (\nArray\n): The range in which the attribute's value should reside in\n\n\n\n\n// Examples\nvalidator('inclusion', {\n in: ['User', 'Admin']\n})\nvalidator('inclusion', {\n range: [0, 5] // Must be between 0 (inclusive) to 5 (inclusive)\n})\n\n\n\n\nBecause of the strict equality comparisons, you can use this validator in many different ways.\n\n\n// Examples\nvalidator('inclusion', {\n in: ['Admin'] // Input must be equal to 'Admin'\n})\nvalidator('inclusion', {\n range: [0, Infinity] // Input must be positive number\n})\nvalidator('inclusion', {\n range: [-Infinity, Infinity] // Input must be a number\n})",
"title": "Inclusion"
},
{
"location": "/validators/inclusion/index.html#options",
"text": "allowBlank ( Boolean ): If true, skips validation if the value is empty in ( Array ): The list of values this attribute could be range ( Array ): The range in which the attribute's value should reside in // Examples\nvalidator('inclusion', {\n in: ['User', 'Admin']\n})\nvalidator('inclusion', {\n range: [0, 5] // Must be between 0 (inclusive) to 5 (inclusive)\n}) Because of the strict equality comparisons, you can use this validator in many different ways. // Examples\nvalidator('inclusion', {\n in: ['Admin'] // Input must be equal to 'Admin'\n})\nvalidator('inclusion', {\n range: [0, Infinity] // Input must be positive number\n})\nvalidator('inclusion', {\n range: [-Infinity, Infinity] // Input must be a number\n})",
"title": "Options"
},
{
"location": "/validators/exclusion/index.html",
"text": "Validates that the attributes\u2019 values are not included in a given list. All comparisons are done using strict equality so type matters! For range, the value type is checked against both lower and upper bounds for type equality.\n\n\nOptions\n\n\n\n\nallowBlank\n (\nBoolean\n): If true, skips validation if the value is empty\n\n\nin\n (\nArray\n): The list of values this attribute should not be\n\n\nrange\n (\nArray\n): The range in which the attribute's value should not reside in\n\n\n\n\n// Examples\nvalidator('exclusion', {\n in: ['Admin', 'Super Admin']\n})\nvalidator('exclusion', {\n range: [0, 5] // Cannot be between 0 (inclusive) to 5 (inclusive)\n})",
Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/public/docs/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@



<li class="toctree-l1 ">
<a class="" href="validators/inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="validators/exclusion/index.html">Exclusion</a>

Expand Down
44 changes: 25 additions & 19 deletions tests/dummy/public/docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@

<url>
<loc>None/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>



<url>
<loc>None/validating/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>



<url>
<loc>None/messages/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>



<url>
<loc>None/templating/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>



<url>
<loc>None/testing/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

Expand All @@ -45,85 +45,91 @@

<url>
<loc>None/validators/common/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/base/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/presence/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/inclusion/index.html</loc>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/exclusion/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/length/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/date/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/format/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/dependent/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/confirmation/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/collection/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/belongs-to/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/has-many/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/function/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

<url>
<loc>None/validators/custom/index.html</loc>
<lastmod>2015-10-06</lastmod>
<lastmod>2015-10-21</lastmod>
<changefreq>daily</changefreq>
</url>

Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/public/docs/templating/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@



<li class="toctree-l1 ">
<a class="" href="../validators/inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="../validators/exclusion/index.html">Exclusion</a>

Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/public/docs/testing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@



<li class="toctree-l1 ">
<a class="" href="../validators/inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="../validators/exclusion/index.html">Exclusion</a>

Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/public/docs/validating/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@



<li class="toctree-l1 ">
<a class="" href="../validators/inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="../validators/exclusion/index.html">Exclusion</a>

Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/public/docs/validators/base/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@



<li class="toctree-l1 ">
<a class="" href="../inclusion/index.html">Inclusion</a>

</li>



<li class="toctree-l1 ">
<a class="" href="../exclusion/index.html">Exclusion</a>

Expand Down
Loading

0 comments on commit 8c8c682

Please sign in to comment.