diff --git a/.all-contributorsrc b/.all-contributorsrc
index 44c7930b..529b1271 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -176,7 +176,9 @@
"name": "Damien Duhamel",
"avatar_url": "https://avatars3.githubusercontent.com/u/3051737?v=4",
"profile": "http://www.damienduhamel.fr",
- "contributions": []
+ "contributions": [
+ "code"
+ ]
},
{
"login": "juliankrispel",
diff --git a/README.md b/README.md
index 7e4a403a..20a6e778 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ These wonderful folks are responsible for developing and maintaining Netlify CMS
| [
CΓ‘ssio Souza](https://twitter.com/cassiozen)
[π»](https://github.com/netlify/netlify-cms/commits?author=cassiozen "Code") | [
Shawn Erquhart](https://erquh.art)
[π»](https://github.com/netlify/netlify-cms/commits?author=erquhart "Code") | [
Andrey Okonetchnikov](http://okonet.ru)
[π»](https://github.com/netlify/netlify-cms/commits?author=okonet "Code") | [
Mathias Biilmann](https://www.netlify.com)
[π»](https://github.com/netlify/netlify-cms/commits?author=biilmann "Code") | [
Benaiah Mischenko](http://benaiah.me)
[π»](https://github.com/netlify/netlify-cms/commits?author=Benaiah "Code") | [
Rafael Conde](http://rafaelconde.net)
[π¨](#design-rafaelconde "Design") [π»](https://github.com/netlify/netlify-cms/commits?author=rafaelconde "Code") | [
Joseph Earl](http://josephearl.co.uk)
[π»](https://github.com/netlify/netlify-cms/commits?author=josephearl "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [
Brian Douglas](https://briandouglas.me/)
[π»](https://github.com/netlify/netlify-cms/commits?author=bdougie "Code") | [
Frances Berriman](https://fberriman.com)
[π¨](#design-phae "Design") | [
David Calavera](https://github.com/calavera)
[π»](https://github.com/netlify/netlify-cms/commits?author=calavera "Code") | [
Luis Correia](https://luisc.pt)
[π»](https://github.com/netlify/netlify-cms/commits?author=lmcorreia "Code") | [
Caleb](https://github.com/tech4him1)
[π»](https://github.com/netlify/netlify-cms/commits?author=tech4him1 "Code") | [
Jerry Holmes](http://www.pagedragon.com)
[π»](https://github.com/netlify/netlify-cms/commits?author=jholmes033169 "Code") | [
abumalick](https://github.com/abumalick)
[π»](https://github.com/netlify/netlify-cms/commits?author=abumalick "Code") |
-| [
Eamonn Bell](http://www.eamonnbell.com)
[π»](https://github.com/netlify/netlify-cms/commits?author=eamonnbell "Code") | [
Jessica Parsons](https://github.com/verythorough)
[π](https://github.com/netlify/netlify-cms/commits?author=verythorough "Documentation") | [
Kyle Mathews](https://www.bricolage.io)
[π»](https://github.com/netlify/netlify-cms/commits?author=KyleAMathews "Code") | [
americool](https://github.com/americool)
[π»](https://github.com/netlify/netlify-cms/commits?author=americool "Code") | [
Damien Duhamel](http://www.damienduhamel.fr)
| [
Julian Krispel-Samsel](http://reactrocket.com)
| [
Kevin McCormack](http://harlemsquirrel.github.io/)
|
+| [
Eamonn Bell](http://www.eamonnbell.com)
[π»](https://github.com/netlify/netlify-cms/commits?author=eamonnbell "Code") | [
Jessica Parsons](https://github.com/verythorough)
[π](https://github.com/netlify/netlify-cms/commits?author=verythorough "Documentation") | [
Kyle Mathews](https://www.bricolage.io)
[π»](https://github.com/netlify/netlify-cms/commits?author=KyleAMathews "Code") | [
americool](https://github.com/americool)
[π»](https://github.com/netlify/netlify-cms/commits?author=americool "Code") | [
Damien Duhamel](http://www.damienduhamel.fr)
[π»](https://github.com/netlify/netlify-cms/commits?author=Dammmien "Code") | [
Julian Krispel-Samsel](http://reactrocket.com)
| [
Kevin McCormack](http://harlemsquirrel.github.io/)
|
| [
Kalin Chernev](https://github.com/kalinchernev)
| [
tortilaman](https://github.com/tortilaman)
| [
VΓ‘clav Klecanda](http://www.vxk.cz)
| [
DrianHillman](http://drianhillman.me)
| [
Sean Crawford](https://github.com/seantcoyote)
| [
Robert Riemann](http://blog.riemann.cc)
| [
Ben Berman](http://jygabyte.com)
|
| [
Benjamin Kniffler](https://github.com/bkniffler)
| [
Mike Wickett](http://www.wickett.ca)
| [
Rory Claasen](http://roryclaasen.me)
| [
Frederic Brodbeck](http://www.freder.io/)
| [
Stuart Dum](https://github.com/simplystuart)
| [
Ryan Watters](https://github.com/rdwatters)
| [
Helder S Ribeiro](https://twitter.com/hsribei)
|
| [
Artem Govorov](http://dm.gl)
| [
CΓ©dric Delpoux](http://xuopled.netlify.com/)
| [
imorente](https://github.com/imorente)
| [
David Francoeur](http://davidfrancoeur.com)
| [
Rusta](https://github.com/Rusta)
| [
Henrik Lau Eriksson](http://henrik.laueriksson.com)
| [
Kraig Walker](https://www.kraigwalker.com)
|
diff --git a/src/components/Editor/EditorControlPane/Widget.js b/src/components/Editor/EditorControlPane/Widget.js
index 9d7f5061..45964d98 100644
--- a/src/components/Editor/EditorControlPane/Widget.js
+++ b/src/components/Editor/EditorControlPane/Widget.js
@@ -6,6 +6,13 @@ import ValidationErrorTypes from 'Constants/validationErrorTypes';
const truthy = () => ({ error: false });
+const isEmpty = value => (
+ value === null ||
+ value === undefined ||
+ (value.hasOwnProperty('length') && value.length === 0) ||
+ (value.constructor === Object && Object.keys(value).length === 0)
+);
+
export default class Widget extends Component {
static propTypes = {
controlComponent: PropTypes.func.isRequired,
@@ -84,14 +91,9 @@ export default class Widget extends Component {
this.props.onValidate(errors);
};
- validatePresence(field, value) {
+ validatePresence = (field, value) => {
const isRequired = field.get('required', true);
- if (isRequired && (
- value === null ||
- value === undefined ||
- (value.hasOwnProperty('length') && value.length === 0) ||
- (value.constructor === Object && Object.keys(value).length === 0)
- )) {
+ if (isRequired && isEmpty(value)) {
const error = {
type: ValidationErrorTypes.PRESENCE,
message: `${ field.get('label', field.get('name')) } is required.`,
@@ -100,10 +102,15 @@ export default class Widget extends Component {
return { error };
}
return { error: false };
- }
+ };
- validatePattern(field, value) {
+ validatePattern = (field, value) => {
const pattern = field.get('pattern', false);
+
+ if (isEmpty(value)) {
+ return { error: false };
+ }
+
if (pattern && !RegExp(pattern.first()).test(value)) {
const error = {
type: ValidationErrorTypes.PATTERN,
@@ -114,7 +121,7 @@ export default class Widget extends Component {
}
return { error: false };
- }
+ };
validateWrappedControl = (field) => {
const response = this.wrappedControlValid();
@@ -126,7 +133,7 @@ export default class Widget extends Component {
} else if (response instanceof Promise) {
response.then(
() => { this.validate({ error: false }); },
- (err) => {
+ (err) => {
const error = {
type: ValidationErrorTypes.CUSTOM,
message: `${ field.get('label', field.get('name')) } - ${ err }.`,