Skip to content

Commit

Permalink
Fix pattern decorator, because the UI expects 'value' instead of 'reg…
Browse files Browse the repository at this point in the history
…exp'
  • Loading branch information
gzsombor committed Apr 21, 2015
1 parent f944d20 commit e2532cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public int size() {
public Object put(String key, Object value) {
return map.put(key, value);
}

public Object remove(String key) {
return map.remove(key);
}

public Object get(String key) {
return map.get(key);
}

private void removeUnusedAttributes(Map<String, Object> annotationAttributes) {
Iterator<String> it = annotationAttributes.keySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.github.valdr.decorator;

import com.github.valdr.ConstraintAttributes;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.github.valdr.ConstraintAttributes;

/**
* Decorates the map of attributes of the {@link javax.validation.constraints.Pattern} constraint.
*/
Expand All @@ -31,12 +32,15 @@ public PatternDecorator(ConstraintAttributes decoratee) {
@Override
public Set<Map.Entry<String, Object>> entrySet() {
Set<Map.Entry<String, Object>> entrySet = getDecoratee().entrySet();
Map<String, Object> result = new HashMap<>();
for (Map.Entry<String, Object> entry : entrySet) {
if ("regexp".equals(entry.getKey())) {
entry.setValue(javaToJavaScriptRegexpPattern(entry));
result.put("value", javaToJavaScriptRegexpPattern(entry));
} else {
result.put(entry.getKey(), entry.getValue());
}
}
return entrySet;
return result.entrySet();
}

private String javaToJavaScriptRegexpPattern(Map.Entry<String, Object> entry) {
Expand Down

0 comments on commit e2532cb

Please sign in to comment.